[Issue 18930] __ctfe fails to detect initialization of unions

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Jun 1 09:01:55 UTC 2018


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

Simen Kjaeraas <simen.kjaras at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |CTFE, diagnostic
                 CC|                            |simen.kjaras at gmail.com

--- Comment #1 from Simen Kjaeraas <simen.kjaras at gmail.com> ---
Unions generally don't work in CTFE. This issue is actually just a case of a
wrong error message - the correct error message is 'Error: reinterpretation
through overlapped field array is not allowed in CTFE', as can be seen in this
code:

union U
{
    int a;
    int b;
}

int fn()
{
    U u;
    u.a = 3;
    return u.b;
}

enum v = fn();

--


More information about the Digitalmars-d-bugs mailing list