Thread overview
[Issue 14643] Safety violation with final switch and void initializer
Jun 02, 2015
Dicebot
Apr 26, 2018
Radu Racariu
Dec 17, 2022
Iain Buclaw
Jan 21, 2023
Nick Treleaven
Jan 21, 2023
Nick Treleaven
Jan 21, 2023
Nick Treleaven
Jan 29, 2023
Nick Treleaven
June 02, 2015
https://issues.dlang.org/show_bug.cgi?id=14643

--- Comment #1 from Dicebot <public@dicebot.lv> ---
correction : foo() needs to be called twice to start getting garbage on stack

--
April 26, 2018
https://issues.dlang.org/show_bug.cgi?id=14643

Radu Racariu <radu.racariu@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |safe
                 CC|                            |radu.racariu@gmail.com

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14643

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

--
January 21, 2023
https://issues.dlang.org/show_bug.cgi?id=14643

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick@geany.org

--- Comment #2 from Nick Treleaven <nick@geany.org> ---
Note that an enum E is allowed to take values larger than E.max using binary operations:

    enum E { a, b}
    pragma(msg, E.max); // E.b which is 1
    E value = E.b << E.b; // 2

So that violates `final switch` anyway, even in @safe code, and casting can (see https://issues.dlang.org/show_bug.cgi?id=11051#c7). Though void initialization is worse because the bug might not even be reproducible. Sadly void initialization is not banned in @safe.

--
January 21, 2023
https://issues.dlang.org/show_bug.cgi?id=14643

--- Comment #3 from Nick Treleaven <nick@geany.org> ---
> the bug might not even be reproducible

Oops, the original bug also violates safety anyway. The above comment combined with the original example means that any enum value outside its min and max properties can produce an uninitialized pointer in safe code, void initialization is not required. The solution seems to be to fix issue 11051.

--
January 21, 2023
https://issues.dlang.org/show_bug.cgi?id=14643

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           See Also|                            |https://issues.dlang.org/sh
                   |                            |ow_bug.cgi?id=11051

--
January 29, 2023
https://issues.dlang.org/show_bug.cgi?id=14643

Nick Treleaven <nick@geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |DUPLICATE

--- Comment #4 from Nick Treleaven <nick@geany.org> ---


*** This issue has been marked as a duplicate of issue 11051 ***

--