<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/158472>158472</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] [x86-64] enum layout without fixed type differs from GCC
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
RalfJung
</td>
</tr>
</table>
<pre>
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
```
<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](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 compiler would disagree here, and it could lead to ABI issues.
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJxsVFGPpDYM_jWeF2sQEwgwDzwws8fqWlWVqkr3eArEQNqQ0CTs7tyvrwLcVtquFIkQO46_z58tvFejIaqB34A_ncQaJuvqP4QeflnNeOqsfNS9FmbE3s7LGsijQKmGgRyZgFo87BowTMLg8_2Og3UYJuWRzDpD1kDaQJEeK23iKXZqRChvkDaIiA1C9oRXxrKsZGlWVDwvS16l1QrsfvjcNp_zZT-B8gmy24fIwCrgt2crO6sD8Cdg1RTC4mMOrAXWjrspsW4E1v4A1j7_82slf-v-JGDXuNKYbQQxqhfyOwyvfhBeCnxVYYpAhXngq3BGmTHBnZfdW4Xdt0JhJHrx8B8TzO7erq4nyL5A1mSQNQVkzc9ocRvZISeCsgZfhF7JI731RBKdMCOhHVALN5IPqEygkRwCv52_xXvnYO15s0bwO20ZQnnHTzjH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