Issue 107554
Summary [Clang Diagnostics] When constexpr evaluation fails, the call stack shows the final value of function arguments, even if they are mutated
Labels clang
Assignees
Reporter MitalAshok
    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)'`.

_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to