[C23] Clang accepts redefinitions with compatible, not same, types for members
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
When implementing WG14 N3037, we missed this bit:
C23 6.7.3.4p1:
> ... If two declarations of the same type have a member-declaration or enumerator-list, one shall not be nested within the other and both declarations shall fulfill all requirements of compatible types (6.2.7) with the additional requirement that corresponding members of structure or union types shall have the same (and not merely compatible) types.
"not merely compatible" is the missing bit. That means we accept code like:
```c
enum E : int { e1 };
struct S1 {
enum E e;
};
struct S1 {
int e;
};
```
https://godbolt.org/z/P6hWd1jde
or
```c
enum F { first };
enum G { second };
struct S2 {
enum F f;
};
struct S2 {
enum G f;
};
```
https://godbolt.org/z/rjW6xb4do
Contributor guide
Assessment
This issue has not been assessed yet.