www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22921] New: ImportC: initializing local with address of

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

          Issue ID: 22921
           Summary: ImportC: initializing local with address of itself
                    does not work in CTFE
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

This does not compile:

struct S
{
    struct S *s;
    int first;
    int *last;
};

int main()
{
    struct S localS =
    {
        &localS,
        0,
        &localS.first
    };

    assertImpl(localS.s == &localS);
    assertImpl(localS.first == 0);
    assertImpl(localS.last == &localS.first);
    return 0;
}

_Static_assert(main() == 0, "Test");

--
Mar 24 2022