これはダングリングポインタ|参照の例です:
#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;
}
少なくともデフォルトのオプションでは、アドレスサニタイザーはそれをキャッチできません。アドレスサニタイザーでそのようなエラーをキャッチすることは可能ですか?
アップデート。
このバグを報告しました: