tbaederr wrote:
For this case:
```c++
constexpr bool test(int& i) {
return __builtin_constant_p(i = 5);
}
constexpr int f() {
int a = 10;
test(a);
return a;
}
static_assert(f() == 5);
```
I simply don't. This also works in GCC.
For
```c++
bool test(int& i) {
return __builtin_constant_p(i = 5);
}
```
both interpreters produce
```llvm
define dso_local noundef zeroext i1 @_Z4testRi(ptr noundef nonnull align 4
dereferenceable(4) %i) #0 {
entry:
%i.addr = alloca ptr, align 8
store ptr %i, ptr %i.addr, align 8
ret i1 false
}
```
in the bytecode case, the bcp call returns false because the bcp call is
evaluated standalone, without the parameters being registered at all. That
means the `DeclRefExpr` to it will be a dummy pointer and modifying those
always fails.
https://github.com/llvm/llvm-project/pull/130143
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits