Issue |
160468
|
Summary |
[clang] Heap-allocated volatile variables are diagnosed as volatile temporaries
|
Labels |
clang:frontend,
clang:diagnostics,
constexpr
|
Assignees |
|
Reporter |
tbaederr
|
See https://godbolt.org/z/r1s5ds5v5
```c++
constexpr int foo() {
for (int i = 0; i != 10; ++i) {
auto *k = new volatile int{0};
int *p = (int *)k;
*p = 10;
delete k;
}
return 1;
}
static_assert(foo() == 1);
```
```console
<source>:11:15: error: static assertion _expression_ is not an integral constant _expression_
11 | static_assert(foo() == 1);
| ^~~~~~~~~~
<source>:6:8: note: assignment to volatile temporary is not allowed in a constant _expression_
6 | *p = 10;
| ^
<source>:11:15: note: in call to 'foo()'
11 | static_assert(foo() == 1);
| ^~~~~
note: volatile temporary created here
```
It's not a temporary though and the source location for the "created here" note is invalid.
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs