-
Notifications
You must be signed in to change notification settings - Fork 14.9k
Open
Labels
ABIApplication Binary InterfaceApplication Binary Interfaceclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.diverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue
Description
clang computes a different layout than GCC for this enum:
enum big {
A = 9223372036854775808u,
B = -1,
};
(Godbolt)
GCC gives this size 16 without any warning. clang gives it size 8 and says
<source>:3:6: warning: enumeration values exceed range of largest integer [-Wenum-too-large]
3 | enum big {
| ^
(On x86-32, clang and GCC both give it size 8 and both emit a warning.)
Whether this is legal C or not depends on whether you consider __int128
to be an "extended integer type" or not... GCC apparently does not, though they do treat it like an extended integer type in many respects, so 🤷 . But legal C or not, it seems surprising that the two compilers would disagree here, and it could lead to ABI issues.
Metadata
Metadata
Assignees
Labels
ABIApplication Binary InterfaceApplication Binary Interfaceclang:codegenIR generation bugs: mangling, exceptions, etc.IR generation bugs: mangling, exceptions, etc.diverges-from:gccDoes the clang frontend diverge from gcc on this issueDoes the clang frontend diverge from gcc on this issue