// g++ str_view_test.cpp -fsanitize=address -std=c++17 -o s #includestd::string f1() { std::string val; val += "123"; val += "456"; return val; } void f2(std::string_view val) { std::cout << val << std::endl; } int main() { //std::string_view ss = f1(); // stack-use-after-scope //f2(ss); f2(f1()); //correct return 0; }
https://docs.microsoft.com/en-us/cpp/sanitizers/error-heap-buffer-overflow?view=msvc-160



