xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/Linux/new_delete_mismatch.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1 // Check that we report new[] vs delete as alloc-dealloc-mismatch and not as
2 // new-delete-type-mismatch when -fsized-deallocation is enabled.
3 
4 // RUN: %clangxx_asan -g %s -o %t && %env_asan_opts=alloc_dealloc_mismatch=1 not %run %t |& FileCheck %s
5 // RUN: %clangxx_asan -fsized-deallocation -g %s -o %t && %env_asan_opts=alloc_dealloc_mismatch=1 not %run %t |& FileCheck %s
6 
7 #include <stdlib.h>
8 
9 static volatile char *x;
10 
main()11 int main() {
12   x = new char[10];
13   delete x;
14 }
15 
16 // CHECK: AddressSanitizer: alloc-dealloc-mismatch (operator new [] vs operator delete) on 0x
17