Issue |
151394
|
Summary |
[clang][c23] Compatibility of structs containing unnamed structs
|
Labels |
clang
|
Assignees |
|
Reporter |
bolshakov-a
|
The issue is somehow similar to #150594, but this time with unnamed record types:
```cpp
struct ContainsUnnamed {
struct {
int i;
} x;
};
struct ContainsUnnamed cu;
int main() {
extern struct ContainsUnnamed y;
struct ContainsUnnamed {
struct {
int i;
} x;
};
extern struct ContainsUnnamed y;
return __builtin_types_compatible_p(struct ContainsUnnamed, typeof(cu));
}
```
https://godbolt.org/z/Yh97EPr59
Again, Clang accepts while GCC rejects. Replacing `struct` with `union` gives the same result.
I think the wording suggests that the code should be rejected because it is stated in 6.2.7 that tag types can be compatible if they are declared with the same tag:
> Moreover, two complete structure, union, or enumerated types declared with the same tag are compatible if ...
but in my example the tag is absent. Moreover, Clang already treats top-level unnamed types as incompatible.
CC @AaronBallman
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs