Skip to content

[warning] Don't report function returns address of local variable #117425

@vfdff

Description

@vfdff

int *foo() {
    int *p = 0;
    {
        int x = 0;
        p = &x;
        *p = 42;
    }
    *p = 42;
    return p;
}
  • I already use -Wall to report all warning, but the dangling pointer is not identified by clang

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerduplicateResolved as duplicatefalse-negativeWarning doesn't fire when it should

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions