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)'.
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)'`.
Consider https://godbolt.org/z/ao786daav:
It has this diagnostic:
Even though it was in a call to
f(0)
. The diagnostic makes it seem likei == 0
. This does not happen with the experimental bytecode interpreter (https://godbolt.org/z/G1exhxfKf), which hasin call to 'f(-1)'
.