Issue |
152279
|
Summary |
Lifetimebound does not detect reference to temporary string chained by member calls
|
Labels |
clang:diagnostics,
clang:memory-safety
|
Assignees |
|
Reporter |
usx95
|
https://godbolt.org/z/vTqzr81qf
```
#include <string>
#include <string_view>
struct S {
const std::string& get() const;
std::string sv;
};
const std::string& S::get() const [[clang::lifetimebound]] { return sv; };
struct T {
const S& get() const;
S s;
};
const S& T::get() const [[clang::lifetimebound]] { return s; }
std::string_view bar() {
S s;
std::string_view a = S{}.get(); // error. Ok.
return s.get(); // error. Ok.
}
std::string_view foo() {
T t;
std::string_view a = T{}.get().get(); // No error. Bug.
return t.get().get(); // No error. Bug.
}
```
_______________________________________________
llvm-bugs mailing list
llvm-bugs@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs