[clang] [x86-64] enum layout without fixed type differs from GCC when big constants are involved
- Dominant language
- LLVM
- Stars
- 40.5k
- Forks
- 18.7k
- PR merge metrics
- PR metrics pending
Description
clang computes a different layout than GCC for this enum:
```
enum big {
A = 9223372036854775808u,
B = -1,
};
```
([Godbolt](https://godbolt.org/z/GqK8dMbTe))
GCC gives this size 16 without any warning. clang gives it size 8 and says
```
: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](https://gcc.gnu.org/onlinedocs/gcc/Integers-implementation.html), 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.
Contributor guide
Assessment
This issue has not been assessed yet.