问题
The following code throws an AddressSanitizer Error when compiled on Debian Jessie with clang 3.5.
It appears to be related to the combination of linked libraries, but i have not been able to find something similar on the internet.
Reproduction of the Error
Invocation: clang++ -stdlib=libc++ -lc++abi -fsanitize=address,vptr sample.cpp -lsupc++ -o sample
//sample.cpp
#include <iostream>
class Foo {
virtual void bar() {
std::cerr << std::endl;
}
public:
virtual ~Foo() { }
};
int main() {
Foo foo;
try{
throw 1;
} catch(int i) {
return i;
}
return -1;
}
When omitting compile flag -lc++abi
, a LeakSanitizer Runtime Error occurs instead.
When omitting any of the other compile flags, no Error occurs.
What causes the error? Is something wrong with my code or is this an invalid combination of compile flags, and if so, what is causing the conflict?
来源:https://stackoverflow.com/questions/33857672/addresssanitizer-leaksanitizer-error-with-lsupc-and-stdlib-libc-on-a-nev