[Issue 23388] New: ImportC: redeclaration of struct in different translation unit doesn’t check compatibility

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Oct 5 15:17:06 UTC 2022


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

          Issue ID: 23388
           Summary: ImportC: redeclaration of struct in different
                    translation unit doesn’t check compatibility
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: accepts-invalid, ImportC
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: dave287091 at gmail.com

// a.c
struct Foo {
    int x;
};
// b.c
struct Foo {
    int x, y;
};
//d.d
import a;
import b;

static assert(a.Foo.sizeof != b.Foo.sizeof); // Fails

The two structs are assumed to be the same type, size etc. and merged into one
instead of iterating over their fields and ensuring all match (in other words,
checking for compatibility before assuming they are the same).

--


More information about the Digitalmars-d-bugs mailing list