This is dangling pointer|reference example:
#include <string>
#include <string_view>
#include <iostream>
std::string foo() {
return "test";
}
int main() {
std::string_view bar = foo(); // bar is pointed to destructed string
std::cout << bar << std::endl;
}
Address sanitizer cannot catch it, at least with default options. Is it possible to catch such errors with address sanitizer?
UPD.
Reported this bug: