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

Kostya Serebryany via cfe-dev cfe-dev at lists.llvm.org
Mon Nov 13 15:41:16 PST 2017


On Mon, Nov 13, 2017 at 7:55 AM, Stephan Bergmann via cfe-dev <
cfe-dev at lists.llvm.org> wrote:

> 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


Why not use "delete [] p1"?


> (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?
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-dev
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20171113/5f138cc6/attachment.html>


More information about the cfe-dev mailing list