<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/84712>84712</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[clang] Invalid rejection of enum arithmetic
</td>
</tr>
<tr>
<th>Labels</th>
<td>
clang
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
davidstone
</td>
</tr>
</table>
<pre>
The following valid translation unit
```cpp
enum e1 {
value = 0
};
enum e2 {
a = 0,
b = e1::value,
c = a + b
};
```
is incorrectly rejected by clang when compiled in C++26 mode with
```console
<source>:8:8: error: invalid arithmetic between different enumeration types ('e2' and 'e1')
8 | c = a + b
| ~ ^ ~
1 error generated.
Compiler returned: 1
```
See it live: https://godbolt.org/z/v4sG9YqMb
In earlier versions of C++, it incorrectly warns saying the conversion is deprecated.
This was accepted in clang 18.1.0, but is failing on current trunk (15e9478187d594016c2c355d8688be2e0a9b554e).
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8VE2z6yYM_TV4o3kZI_y58OIm96XzFl31bbrkQ4lpCaSAk0kX77d3sHPbtHOnjI1tIR2Jc2RkSvbsiSbW7ln7XsklzyFORt6sSTl4qlQwj-n7THAKzoW79We4SWcN5Ch9cjLb4GHxNrP6ndVvz7mrt0tfr5uF_HIB4sD6_YfjeJNuIWDiHeqnrX9nYv8KtIXhv8LkMwQPf5vUaiLOxBsTbyvu67JelyUw3IP6JNVHta-ZbQLrdYiRdHYPiPQb6UwG1AO0k_4M95k86HC5WkcGrIcDwz3DPXZwCYbgbvP8OSfBp-DoaRWHFJaoiYmvTLwNzxsoxhDLi_Ub3TLaPF8oWw2K8p3Ig7GnE0XyGQpNFDct8uNKCRgODHtChj1Ib6B8cIY9w3FLDAAwAOsP8DE-YWlbeHUq4wew9iv82Fz4ViqcyZcKyOw2-2FjJkKkvERPpmyG_w_hvxCBzeDsjYrrnPM1FT3xyPB4DkYFl3chnhke_2R4vDXpp_HXP35WrxjfPJCMzlKEG8Vkg08QTh_KMDyUDK-y3mX0CZJ8lL7OM4EO_hkJNoGhayT9sqtt_j7bBHeZQGpN17zJv3UFH3Z8V3oT1JILxElaV8CDB73EVa0cF_97UYi3NDb9wIfetGNT806jFm1rhm4YFCHVclRt2xDDcVeZSZhRjLKiife85jiMw1DNU183XdvxXnBdNxzFibfYCNF1mnotzFjZCWtsasF5LZqxGXZKjiMa0apekeyUZk1NF2ndzrnbpVBc2ZQWmoam51g5qcil9YBAXDfJEMtZEafi_0Ut58Sa2tmU0z8I2Wa3nipbRPsO356NvP1JheBwWhv3pbWrJbrpP8rbPC9qp8OF4bHAPx9frjEUIIbHtdrE8LgW_FcAAAD__3uhas8">