-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Open
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)
Description
Similar to issue #99685.
Trivial forwarding helpers defeat the compiler's ability to notice -Wdangling-gsl issues. For example:
#include <string>
#include <utility>
struct [[gsl::Pointer]] S {
S(const std::string&);
};
template <typename T>
[[clang::always_inline]] S fwd(T&& t) {
return S(std::forward<T>(t));
}
[[maybe_unused]] static void f() {
[[maybe_unused]] S s1(std::string("123")); // Marked dangling, yay!
[[maybe_unused]] S s2(fwd(std::string("123"))); // Not marked dangling, boo :(
}
Live example: https://godbolt.org/z/T5q3zj6eo.
Metadata
Metadata
Assignees
Labels
clang:diagnosticsNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerNew/improved warning or error message in Clang, but not in clang-tidy or static analyzerclang:temporal-safetyIssue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)Issue/FR relating to the lifetime analysis in Clang (-Wdangling, -Wreturn-local-addr)
Type
Projects
Status
No status