[Issue 14643] Safety violation with final switch and void initializer

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Jan 21 16:47:32 UTC 2023


https://issues.dlang.org/show_bug.cgi?id=14643

Nick Treleaven <nick at geany.org> changed:

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

--- Comment #2 from Nick Treleaven <nick at 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.

--


More information about the Digitalmars-d-bugs mailing list