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

    <tr>
        <th>Summary</th>
        <td>
            [Clang] Does not catch undefined behavior in post-increment during constant evaluation
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            clang:frontend,
            confirmed,
            undefined behaviour,
            constexpr
      </td>
    </tr>

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

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

<pre>
    As noted by [cwg2855](https://github.com/cplusplus/CWG/issues/479) the following code invoked undefined behavior:

```cpp
#include <cstdint>

int8_t constexpr f() {
  int8_t x = 127;
  return x++;
}

int8_t constexpr x = f();
```

We should catching this during constant evaluation, so the code above should be ill-formed, but we currently don't: https://godbolt.org/z/PY465bTzo
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJx8U0uPozgQ_jXFpZQIDA7hwCEJm73uYaXWnlZ-FMHTjh35kX78-hEk3R3NjFoyIOr1lb-qT8RoTo6oB74HPhQip8mHPk5iNM-F9Pqt30V0PpFG-YbA9-rlxLacAx-AbaeULhHqHbAjsOPJpCnLtfJnYEd1sTnOD7Dj4elvYEcTY6b5t2k7YB2miXD01voX406ovCY07uqfSWN2mkbjZlCaxNX4MIOUA5Qf7015O-pyuVtYbZyyWRNCfVAxaeMS1H89ZhmXtv8nVN7FRK-XgCOw7dwKtPtbBOI95hWhHrBiLdSfrkApB4evwPbz-XBAO3wLcit1h_rK-rjBY-4TYZx8thqVSGqaeUmTiahzuHHkYhIuIV2FzSIZ74AdMPqFy4VBIf31s4gkNNauRh_OpOdImRO-EKocArlk31DPFdoE9Q5_maXX0tu09uEE7PgO7PjPf82Gy3_ffaH7Wnd1Jwrqq7bcVlXXbtpi6jtRN5q3lRTVOHZly0tZy2pTjYLXo-yoMD0rWVOyasOqhjXteuScq63ksiYSXbOBpqSzMHZt7fU8YxfL0vRbVjZ1YYUkG5dVZUxZ4U5Q78bgXSKngTFgh9nh3WhuF75bftumHB6jb2OaLXwoQj9Dr2Q-RWhKa2KKX80kk-wilcMCzgccPC3yuM3rD3uLxuHFx7QyTgU6k0vfDLPIwfbfaGpu5P5ZXYL_QSo96mph6WcAAAD__6VkMlc">