Skip to content

clang 17/18: Adding UBSan makes ASan message disappear #92386

Open
@pkl97

Description

@pkl97

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;
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions