Issue 110360
Summary [ASAN] AddressSanitizer FN, failed to report memory leak
Labels new issue
Assignees
Reporter wr-web
    reproduce: https://godbolt.org/z/WEjY9rY1G
bug code:
```cpp
#include <iostream>

void unsuspectingBug() {
    int* ptr = new int(42);

    // Perform some logical operations that don't affect ptr directly
    for (int i = 0; i < 100; ++i) {
        int temp = i * i; // Irrelevant computation
        if (temp == 42) {
            delete ptr;
        }
    }

    // Forgetting to nullify ptr after deletion
    // Logical usage without realizing it's been erased
    if (ptr) {
        std::cout << *ptr << std::endl; // Dereference of dangling pointer not realized due to logical oversight
    }
}

int main() {
    unsuspectingBug();
    return 0;
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to