www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22236] New: sizeof an empty C struct should be 0, not 1

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

          Issue ID: 22236
           Summary: sizeof an empty C struct should be 0, not 1
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: bugzilla digitalmars.com

To match typical C compiler behavior. (The sizeof is 1 for C++.)

The following program will print 0 for C, 1 for C++. D currently regards both
as 1.

  #include <stdio.h>
  struct S { };
  int main() {
    printf("%d\n", sizeof(struct S));
  }

--
Aug 24