<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/106815>106815</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Range of empty enumeration without fixed underlying type is incorrect.
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
keinflue
</td>
</tr>
</table>
<pre>
The following currently compiles without diagnostic for C++11 up to C++23:
```
enum E {};
constexpr auto x = static_cast<E>(1);
```
This should be ill-formed, clearly in C++17, and also intended in C++20 and later.
According to [[dcl.enum]/8](https://timsong-cpp.github.io/cppwp/n4659/dcl.enum#8) the set of values of `E` is only `{0}` and therefore the cast has undefined behavior.
In C++20 the wording of [dcl.enum]/8 changed and now isn't clear any more, but presumably there was no intent to change the behavior. See https://github.com/cplusplus/CWG/issues/604.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8k0uvqzYQxz-N2YwOMia8FixuTg5Vt-2VuqyMPYBbYyM_ksO3r0xy05xWuhLYjGEe_x8z3Hs1G8SeVGdSXTIew2Jd_zcqM-mI2Wjl3n9fECartb0pM4OIzqEJegdh101p9HBTYbExgFR8NtYHJWCyDt4JOxN2LgqIGwT7w2YlKb8ReiH0x1rTx3WYaOIKH0CaM2kupDzfT4U1PuDn5oDHYOETSHkBH3hQ4k_BfSDl-wcpPwhrC8K6p9t_Yt_X74vy4BcbtYQRQWn9Nlm3oiTsHYRG7vQOyjwFNOmcGwlcewvKBDQS5csXjB6vNQ_o8tdM34SwTiZswcLB-CyFzpNEUl0IG9pja5cQNp-wsIGwIajVWzO_iW3LZxWWOObKEjaIbbtthA3mVFcdYcMzFCtbwjoIC4LHAHaCK9cRfXoiNf0gNQXlwRq9J5s0Z5rY1veyw4IOJ-vwCJBgwsI9RCNxUgYTo4Vflf0q7ddX9cnx9lCacv5PJoiFmxnlkdDYGyhvCGvCHTdws8NqHSbQYwywOfRx5aPe79XBjXswD_YhwbzHOxI_y4PfEeErygc-YdeDn44-3YQN73_8QtigvI-YzJqe8kz2pezKjmfYFw2raF03Lc2Wvqq6duzEWBTT1IxFKzomu-6ErZhGOZU0Uz2j7ETbsqBFUVKaF42sWjoxKjp-oh0jJ4orVzrX-rrm1s3ZkbkvaN0WVab5iNofQ8iY0NzMhLE0j65PDm9jnD05Ua188P-GCCroY3LvHtUFfjuY2Alw3cIOiT86HpQ1zxmd1CfK4986vR-NuW-YmkMZYZ1DEfIsOt3_BGMq4LG9bc7-hSK8onxouvbsnwAAAP__L-1ecg">