Issue 169548
Summary [LifetimeSafety] False positive for pointers declared in a loop
Labels clang:temporal-safety
Assignees
Reporter usx95
    ```cpp
bool cond();

void foo() {
    for (; cond();) {
        int obj;
 int* view;
        if (cond()) {
            view = &obj;
        }
 (void)*view; // error: use-after-scope.
 }
}
```
https://godbolt.org/z/MvrdMaKK4

My idea to fix this is to issue a Kill/Reset when process the `DeclStmt`.  The problem currently is that decl `int* view;` does not kill the original value from the last iteration.

We can choose to have this warning as this is otherwise a **use-of-uninitialised** value
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to