-
Notifications
You must be signed in to change notification settings - Fork 14.6k
Open
Labels
c23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second party
Description
The following code is accepted by clang but rejected by GCC (C23 mode):
enum E : int {A, B, C};
enum E e;
int main() {
extern enum E Fn();
enum E {A, B, C};
extern enum E Fn();
return __builtin_types_compatible_p(enum E, typeof(e));
}
https://godbolt.org/z/Eab5nz3q9
Compiled by clang, it returns 1, whereas if compiled by GCC (provided that the second Fn()
declaration is removed) it returns 0.
I think GCC behavior is correct because 6.2.7 "Compatible type and composite type" states:
For two enumerations, ... if one has a fixed underlying type, then the other shall have a compatible fixed underlying type.
Metadata
Metadata
Assignees
Labels
c23clang:frontendLanguage frontend issues, e.g. anything involving "Sema"Language frontend issues, e.g. anything involving "Sema"confirmedVerified by a second partyVerified by a second party