#include <iostream>
#include <string>
#include <string_view>
struct S {
std::string_view data;
};
S getS(const std::string& s [[clang::lifetimebound]]) { return S{s}; }
void foo() {
S s;
{
std::string str = "small scoped string";
s = getS(str);
}
std::cout << s.data; // use-after-free
}
https://godbolt.org/z/9s1xqc3nW