[cfe-dev] ASan alloc-dealloc-mismatch and placement new

Stephan Bergmann via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 13 07:55:43 PST 2017


For a C++ program like

> #include <new>
> int main() {
>     char * p1 = new char[sizeof (int)];
>     int * p2 = new(p1) int;
>     delete p2;
> }

compiling it with -fsanitize=address will somewhat unhelpfully report an 
"AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator 
delete)" failure.

Is there a good way to work around that (in the program's source code), 
short of using the generic ASan facilities of suppressing or 
blacklisting code, or using ASAN_OPTIONS=alloc_dealloc_mismatch=0 to 
disable the check completely?


More information about the cfe-dev mailing list