I'm using gcc and clang-embedded sanitizers for a little, including address sanitizer. And things work pretty well, but on next demo code I get no output related to a error despite it is there (to be more precise -- no output at all):
#include <string>
#include <iostream>
using std::string;
using std::cout;
class Foo
{
string _member;
public:
Foo(): _member("just a string") {}
const string& get() const { return _member; }
};
const string& bar()
{
// returning reference to a temp object on stack
return Foo().get();
}
int main()
{
cout << bar() << '\n';
return 0;
}
I tried g++ -O0 -g -fsanitize=address test.cc
and same with clang++
: g++-version just prints nothing, clang one prints garbage for a long time.
Valgrind on non-instrumented binary gives feedback:
Syscall param write(buf) points to unaddressable byte(s)
.
Is it internal asan problem or I'm doing something wrong?
Versions: gcc 4.9.2, clang 3.6.0