[asan] failure to detect memory leaks · Issue #129842 · llvm/llvm-project (original) (raw)

Skip to content

Provide feedback

Saved searches

Use saved searches to filter your results more quickly

Sign up

Appearance settings

@PikachuHyA

Description

@PikachuHyA

reproducer
see https://godbolt.org/z/6YGdnn634

// main.cc struct Foo { struct Foo *other; }; int main() { auto f1 = new Foo(); auto f2 = new Foo(); f1->other = f2; f2->other = f1; return 0; }

However, the following memory leaks detected.

see https://godbolt.org/z/n6jWbYTqY

struct Foo { struct Foo *other; }; int main() { auto f1 = new Foo(); auto f2 = new Foo(); f1->other = f2; // highlight here // f2->other = f1; return 0; }

Note: GCC can detect the memory leaks.
if use -fsanitize=leak, the memory leaks detected.