Open
Description
Compiling the program below with clang++ -Wall -Wextra -g -fsanitize=address main.cpp
shows the expected memory leak.
==1548781==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 4 byte(s) in 1 object(s) allocated from:
...
However if compiled with clang++ -Wall -Wextra -g -fsanitize=address,undefined main.cpp
it no longer generates any output.
This happens with clang 17.0.6 and 18.1.1.
If the memory allocation is moved to function f() then the combination of ASan and UBSan works fine.
Is this the expected behavior?
The test program:
void r()
{
int* iptr=new int(3);
}
void f()
{
r();
}
int main()
{
f();
return 0;
}