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

    <tr>
        <th>Summary</th>
        <td>
            [Clang Diagnostics] When constexpr evaluation fails, the call stack shows the final value of function arguments, even if they are mutated
        </td>
    </tr>

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

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

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

<pre>
    Consider <https://godbolt.org/z/ao786daav>:

```c++
constexpr int f(int x) {
    ++x;
    return x / x;
}

constexpr int i = -1;
static_assert(f(i) == 1);
```

It has this diagnostic:

```
<source>:7:15: error: static assertion expression is not an integral constant expression
    7 | static_assert(f(i) == 1);
      |               ^~~~~~~~~
<source>:3:14: note: division by zero
    3 |     return x / x;
      |              ^ ~
<source>:7:15: note: in call to 'f(0)'
    7 | static_assert(f(i) == 1);
      |               ^~~~
```

Even though it was in a call to `f(0)`. The diagnostic makes it seem like `i == 0`. This does not happen with the experimental bytecode interpreter (<https://godbolt.org/z/G1exhxfKf>), which has `in call to 'f(-1)'`.

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy0VEGPqzYQ_jXmMtrImADhwGFfsqmqqrdKPVYDDNhdx45sk82-Q397NSSb5LVvq_ZQC8XEzOf5vm_GxhjN5IhaUX4R5S7DOWkf2p9NQvsctX_NOj-8t1vvohkogCi2OqVjFMWzUHuh9pMfOm_TyodJqP1Xofbo6001IJ5E8cJhcifkx28lL08v1Bd-ltXeu5jofAxgXIJRqA3PZ6EaEPU1BgDggjmL4mEtUJqDgzMItYf7J1HvHvN-m8GAKHbwlN-iY8Jk-t8wRgpJqM1CYUlf7Dg0F6q5b_2h4THBjwk0RkjaRBgMTs7HZPrP1F__Ftvo59DTxadaFM95KYpnoBB84JcLL7jwMt4BS6AY-dVEcD4BOpZEU0ALi0p06SHsblQNot7Cf1IKy2DYt0OUL39cx3eVFKxkzQKcT8TzYE5mYd29w1cK_r5_cdv_k0p-QkKUL_D97HcfP7IbBz1aC8mDUDVLlixT1f-jO__QKy8ncpC0nycNJsEbRmaId46VvHGs5Ap-0fTQU3DAV4oMjEQHsOaVGGE-OMorhhvR06VJNB6P5ODNJA1JE_cHBXMgl9BC956o9wMtfRSOgRIfc7X5Fyf9h5zO-jz-NLLz7OgW3rTp9XIWmNTfjH_Kr85XcnVxIxvaYmiKBjNq81qVVV6pepPpVpabJi-rJq8KWjdKFuuylsNYNyUqVXdjZlol1Vo2spJNmeeblVJdIbHfVKXKsZa1WEs6oLEra08Hpp2ZGGdqc1mX5Tqz2JGNy8WnVG_RTUIpvgNDy4Cnbp6iWEtrYor3LZJJdrktt4yA3a0wUZQ7-FWTg_ttQye0My5Hd0RjIzvEBVhciQn7V4jav8VlcTQOLTCCwI8wzq5fkBimmWu1oImbx4wMeAcMBIc5YaIhm4Nt_1Ivk_TcrXp_EGrP_K_T0zH436lPQu0XP6JQ-6slp1b9GQAA___mB8He">