<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/62686>62686</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
Incorrect -Wenum-constexpr-conversion warning?
</td>
</tr>
<tr>
<th>Labels</th>
<td>
false-positive
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
thesamesam
</td>
</tr>
</table>
<pre>
With this (derived from Kleopatra, see https://bugs.gentoo.org/903576):
```c++
enum foo { x = 0xffff };
constexpr auto bar = static_cast<foo>(x + 1); /* fails */
static_assert (sizeof (x) == 4);
```
trunk gives:
```console
<source>:2:26: error: integer value 65536 is outside the valid range of values [0, 65535] for this enumeration type [-Wenum-constexpr-conversion]
constexpr auto bar = static_cast<foo>(x + 1); /* fails */
^
```
It's getting the type right but not the range of valid enum values?
Thanks to @ArsenArsen for reducing it.
cc @shafik
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0U02P4zYM_TX0hUjgSLYTH3xIJhtg0WuBPRaKTNnqOFIg0mm2v76QJmini7a3BpJC048f78k0zH4KRAO0J2jPlVlljmmQmdjc8q6ucfw-fPMyo8yeEdRhpOQfNKJL8YY_LRTvRpIB9YZMhLPInUEfQV1AXa7rxNuJgsS4jWkCdelr3e47UH3G1Geoj9DVH8uCOuVVvBTWG7oYEfYnfCLoM9ZP55xD2J9Bv1A2BhZ63hOaVSJeTSpIFiPe_mINC-g3FyPoL6AOTwR1wl0pfsLS4RGd8UvmVTouSV_RhpmSZMbsf6fosvUE1ecKuUjzkecHEq_HckpawztO_kH8D2xj4LjQy6vfOK7JUm5UH1XeHegjUkoxZcMHoYkSPsyyEnZtqzv0jHEV9iOhzJRf-RGTCRNhdB9IRmhPdb6cHNJCe0YX08ddZokpGfExoHy_U4ZuvmXv5k9ds_WgxD4GaM__o-j4bz9ov_ygHH7W-KuA2jNOJOLDVHQoXJKfZsHrKhiiFPdnYfxY2L80An35nPLn2YR3RokITX1MTKEcRbhE42pzIS_bzzHWZjDPxvn3ahz02OveVDTsuoPuVb3TTTUP9X7fXDvbUacbZZuDskppp12z3_WW1KHyg6qVrtud2vW61c22ceQs1a4nNfZm7KCp6Wb8sl2Wxy1PVOWZVxo61R26ajFXWrjMslLOLEybe2Qv_kGgVJ7vNOTATR5LaOrFs_BfqcTLQsPXYGNKZAX_41vA30wKPkygL9WaluHvUz95mdfr1sYbqEtO__rb3FP8layAupS2GdSldP5HAAAA__-nqV3V">