www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24155] New: ImportC: empty braces not accepted as struct

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

          Issue ID: 24155
           Summary: ImportC: empty braces not accepted as struct
                    initializer
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: dave287091 gmail.com

Following fails to compile:

    struct S {
        int x;
    };
    struct S s = {}; // Error: expression expected, not `}`

Before C23, this was a common C extension to 0-initialize all fields (accepted
by GCC, clang, and maybe MSVC (not sure on that one)). C23 has also added it to
standard C.

--
Sep 23 2023