Skip to content

-Wdangling warning on std::unique_ptr<int>(nullptr).get(). #97471

Closed as not planned
@hokein

Description

@hokein

This is an interesting case:

const int* p2 = std::unique_ptr<int>(nullptr).get();  

Clang emits a object backing the pointer will be destroyed at the end of the full-expression warning. For this case, we know that the result p2 is nullptr, this is not a dangling case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerquestionA question, not bug report. Check out https://llvm.org/docs/GettingInvolved.html instead!

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions