www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - =?UTF-8?B?W0lzc3VlIDIzMzg4XSBOZXc6IEltcG9ydEM6IHJlZGVjbGFyYXRp?=

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 puremagic.com
          Reporter: dave287091 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).

--
Oct 05 2022