Skip to content

Detect dangling references for C++20's Parenthesized Aggregate Initialization  #101957

Closed
@usx95

Description

@usx95
struct MyThing {
    const std::string& s;
};

MyThing makeThing(std::string s) {
    return MyThing(s);
}

https://godbolt.org/z/6335YcKMM

This also doesn't work for gsl::Pointer types like string_view instead of const std::string&. https://godbolt.org/z/8bcaxTqjY

This is different from #58985. This still only needs stmt-local analysis and has probably a simple fix.

Metadata

Metadata

Assignees

Labels

clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:frontendLanguage frontend issues, e.g. anything involving "Sema"clang:memory-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions