| Issue |
239421
|
| Summary |
[LifetimeSafety] False positive "parameter is later invalidated" when destroying a range with p->~T() in a loop
|
| Labels |
clang:temporal-safety
|
| Assignees |
|
| Reporter |
ahatanak
|
$ cat test.cpp
```
struct S {
~S();
};
void destroy(S *first, S *last) {
for (; first != last; ++first) {
first->~S();
}
}
```
$ clang++ -Wlifetime-safety-experimental-invalidation -std=c++26 -c test.cpp
test.cpp:5:14: warning: parameter 'first' is later invalidated [-Wlifetime-safety-experimental-invalidation]
5 | void destroy(S *first, S *last) {
| ^~~~~~~~
test.cpp:7:12: note: parameter 'first' is invalidated here
7 | first->~S();
| ~~~~~~~^~~~
test.cpp:7:5: note: later used here
7 | first->~S();
| ^~~~~
1 warning generated.
After `++first`, `first` points to a different element, so the next `first->~T()` does not touch anything already destroyed.
I haven't bisected, but it looks like this is caused by #195064.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs