[clang] [Clang][Interp] Create the variable that holds the value of evaluating the binding (PR #100565)

via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 25 06:47:57 PDT 2024


yronglin wrote:

> Why is creating those variables necessary, what part about the reproducer doesn't work in the current interpreter, and why would the new one support it?

Seems current interpreter treats `&sre == &__real scf` and `&sim == &__imag scf` not an integral constant expression. 
https://godbolt.org/z/hMEaxax6W

```
➜  test ../rel/bin/clang -c  -fexperimental-new-constant-interpreter ./bug1.cpp
➜  test ../rel/bin/clang -c  ./bug1.cpp 
./bug1.cpp:6:19: error: static assertion expression is not an integral constant expression
    6 |     static_assert(&sre == &__real scf);
      |                   ^~~~~~~~~~~~~~~~~~~
./bug1.cpp:3:12: note: initializer of '[sre, sim]' is not a constant expression
    3 |     auto &[sre, sim] = scf;
      |            ^
./bug1.cpp:3:11: note: declared here
    3 |     auto &[sre, sim] = scf;
      |           ^
./bug1.cpp:7:19: error: static assertion expression is not an integral constant expression
    7 |     static_assert(&sim == &__imag scf);
      |                   ^~~~~~~~~~~~~~~~~~~
./bug1.cpp:3:17: note: initializer of '[sre, sim]' is not a constant expression
    3 |     auto &[sre, sim] = scf;
      |                 ^
./bug1.cpp:3:11: note: declared here
    3 |     auto &[sre, sim] = scf;
      |           ^
2 errors generated.
```

https://github.com/llvm/llvm-project/pull/100565


More information about the cfe-commits mailing list