<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/58127>58127</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            Incorrect description of `-Wenum-constexpr-conversion`
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pogo59
      </td>
    </tr>
</table>

<pre>
    In https://discourse.llvm.org/t/clang-16-notice-of-potentially-breaking-changes/65562 @AaronBallman describes `-Wenum-constexpr-conversion` this way:
* Clang will now correctly diagnose as ill-formed a constant expression where an enum without a fixed underlying type is set to a value outside the range of the enumeration’s values.

```
    enum E { Zero, One, Two, Three, Four };
    constexpr E Val1 = (E)3;  // Ok
    constexpr E Val2 = (E)7;  // Ok
    constexpr E Val3 = (E)8;  // Now diagnosed as out of the range [0, 7]
    constexpr E Val4 = (E)-1; // Now diagnosed as out of the range [0, 7]
```
I think the actual "range" of the enumeration is [0, 4] not [0, 7] and therefore clang should diagnose the second example `(E)7`.

Alternatively, the diagnostic should be _described_ differently, in order to accurately specify the conditions that are being diagnosed.  Perhaps instead of "outside the range of the enumeration's values" it should be "outside the range of the minimum-size bitfield needed to represent the range of the enumeration's values."

But I'd rather see this handled as a bug, and fixed accordingly.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJylVU1v2zgQ_TXyZSBDH5YsH3SI6wTIpd1D0QK9FLQ4stnQpEBScb2_vo-ynTjFdjfAGnIUhvP55s3L1spT-2hoH8Lgk_IuKR7wSOU7OzrPc62fD3PrdvhjwLfTwuzSvE6NDarj1PbpYAOboITWp3TrWDwpWHR72LGHR11VdUHJIrsTzpo1zA7CkGTfObVlT0mdpV_ZjIe0s8YH_jm4-NszO6-swS2FvfJ0FKdYXbZJMtR4Rx9iIXRUWpOxR-qsc9wFfSKpxM5YzyQ84TbtrTu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