https://godbolt.org/z/GerTP67dc
#include <string>
#include <string_view>
struct S {
std::string_view x() const [[clang::lifetimebound]];
std::string i;
};
std::string_view S::x() const { return i; }
void G() {
std::string_view x;
{
S s;
x = s.x(); // No error. Bad.
}
(void)x;
}
std::string_view LB(std::string_view in [[clang::lifetimebound]]);
std::string_view LB(std::string_view in) { return in; }
void foo() {
std::string_view x;
{
std::string s;
x = s; // Error! Good.
}
(void)x;
}