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

            Bug ID: 115619
           Summary: [ASAN] new-delete-type-mismatch on aligned operator
                    new
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: sanitizer
          Assignee: unassigned at gcc dot gnu.org
          Reporter: thiago at kde dot org
                CC: dodji at gcc dot gnu.org, dvyukov at gcc dot gnu.org,
                    jakub at gcc dot gnu.org, kcc at gcc dot gnu.org
  Target Milestone: ---

Simple test case:

#include <new>
int main()
{
    delete new (std::align_val_t(64)) char;
}

Produces:

=================================================================
==31603==ERROR: AddressSanitizer: new-delete-type-mismatch on 0x509000000040 in
thread T0:
  object passed to delete has wrong type:
  size of the allocated type:   1 bytes;
  size of the deallocated type: 1 bytes.
  alignment of the allocated type:   64 bytes;
  alignment of the deallocated type: default-aligned.
    #0 0x7f8abfefd0d8 in operator delete(void*, unsigned long)
(/lib64/libasan.so.8+0xfd0d8) (BuildId:
1827a4c72065a9f25ba519b25166029eebbf519f)
    #1 0x40118a in main (/tmp/asan+0x40118a) (BuildId:
8bfb14839297ab61e6a8de28f913cc801a1f7cd7)
    #2 0x7f8abf62a1ef in __libc_start_call_main (/lib64/libc.so.6+0x2a1ef)
(BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)
    #3 0x7f8abf62a2b8 in __libc_start_main_alias_2 (/lib64/libc.so.6+0x2a2b8)
(BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)
    #4 0x401094 in _start ../sysdeps/x86_64/start.S:115

0x509000000040 is located 0 bytes inside of 1-byte region
[0x509000000040,0x509000000041)
allocated by thread T0 here:
    #0 0x7f8abfefc708 in operator new(unsigned long, std::align_val_t)
(/lib64/libasan.so.8+0xfc708) (BuildId:
1827a4c72065a9f25ba519b25166029eebbf519f)
    #1 0x401178 in main (/tmp/asan+0x401178) (BuildId:
8bfb14839297ab61e6a8de28f913cc801a1f7cd7)
    #2 0x7f8abf62a1ef in __libc_start_call_main (/lib64/libc.so.6+0x2a1ef)
(BuildId: a2c0942c27fb9483b47886a1b937337a797bbceb)

SUMMARY: AddressSanitizer: new-delete-type-mismatch
(/lib64/libasan.so.8+0xfd0d8) (BuildId:
1827a4c72065a9f25ba519b25166029eebbf519f) in operator delete(void*, unsigned
long)
==31603==HINT: if you don't care about these errors you may set
ASAN_OPTIONS=new_delete_type_mismatch=0
==31603==ABORTING

Reproduced with GCC 13, 14 and with Clang 18.

Reply via email to