Dangling false positive if the the owner is also moved in the initializer. #114201
Labels
clang:diagnostics
New/improved warning or error message in Clang, but not in clang-tidy or static analyzer
clang:memory-safety
Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)
This issue is identified in #112751.
When we add the
clang::lifetimebound
annotation tounique_ptr::get()
, clang emits a dangling-field warning for thepointer(up.get())
member initializer. This warning is a false positive in this context, as theowner
member is moved as part of the initialization, retaining ownership.Another example occurs in designated-initializer cases:
Fixing these false positives is hard because it would require tracking dependencies between expressions, which is beyond the capabilities of the current statement-local analysis.
The text was updated successfully, but these errors were encountered: