At least on Linux,
clang++ -fsanitize=address test.cc
on
#include <cstddef>
#include <new>
void * operator new(std::size_t) throw (std::bad_alloc) { return 0; }
int main() {}
fails for me with
/tmp/test-d17df6.o: In function `operator new(unsigned long)':
test.cc:(.text+0x0): multiple definition of `operator new(unsigned long)'
/home/sbergman/clang/trunk/inst/bin/../lib/clang/3.5.0/lib/linux/libclang_rt.asan-x86_64.a(asan_new_delete.o):/home/sbergman/clang/trunk/src/projects/compiler-rt/lib/asan/asan_new_delete.cc:62: first defined here
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Is that a known problem? I assume there is no good way around it as the asan code is linked -whole-archive into the executable from a static archive (instead of using a dynamic library as GCC appears to do it, which also avoids the incompatibility with -z defs).
Stephan