https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107531

--- Comment #4 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to nightstrike from comment #0)
> Maybe adding something from -fsanitize=undefined would be an option?

There's nothing undefined in your example.

But if you actually allocate and free resources, asan aborts on the
double-free:

=================================================================
==1035874==ERROR: AddressSanitizer: attempting double-free on 0x602000000010 in
thread T0:
    #0 0x7f69bd2bc088 in operator delete(void*, unsigned long)
(/lib64/libasan.so.8+0xbc088)
    #1 0x401391 in S::~S() (/tmp/a.out+0x401391)
    #2 0x401247 in main (/tmp/a.out+0x401247)
    #3 0x7f69bca2950f in __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58
    #4 0x7f69bca295c8 in __libc_start_main_impl ../csu/libc-start.c:389
    #5 0x4010f4 in _start (/tmp/a.out+0x4010f4)

0x602000000010 is located 0 bytes inside of 4-byte region
[0x602000000010,0x602000000014)
freed by thread T0 here:
    #0 0x7f69bd2bc088 in operator delete(void*, unsigned long)
(/lib64/libasan.so.8+0xbc088)
    #1 0x401391 in S::~S() (/tmp/a.out+0x401391)
    #2 0x401577 in void f<S>(S const&) (/tmp/a.out+0x401577)
    #3 0x40123b in main (/tmp/a.out+0x40123b)
    #4 0x7f69bca2950f in __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58

previously allocated by thread T0 here:
    #0 0x7f69bd2bb188 in operator new(unsigned long)
(/lib64/libasan.so.8+0xbb188)
    #1 0x4012e3 in S::S() (/tmp/a.out+0x4012e3)
    #2 0x40122f in main (/tmp/a.out+0x40122f)
    #3 0x7f69bca2950f in __libc_start_call_main
../sysdeps/nptl/libc_start_call_main.h:58

SUMMARY: AddressSanitizer: double-free (/lib64/libasan.so.8+0xbc088) in
operator delete(void*, unsigned long)
==1035874==ABORTING

Reply via email to