Open
Description
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.