xref: /llvm-project/compiler-rt/test/gwp_asan/use_after_delete.cpp (revision a62586846fa90054bd9224912b07095d2fca662c)
121184ec5SMitch Phillips // REQUIRES: gwp_asan
221184ec5SMitch Phillips // RUN: %clangxx_gwp_asan %s -o %t
321184ec5SMitch Phillips // RUN: %expect_crash %run %t 2>&1 | FileCheck %s
421184ec5SMitch Phillips 
521184ec5SMitch Phillips // CHECK: GWP-ASan detected a memory error
6*a6258684SMitch Phillips // CHECK: Use After Free at 0x{{[a-f0-9]+}} (0 bytes into a 1-byte allocation
721184ec5SMitch Phillips 
821184ec5SMitch Phillips #include <cstdlib>
921184ec5SMitch Phillips 
main()1021184ec5SMitch Phillips int main() {
1121184ec5SMitch Phillips   char *Ptr = new char;
1221184ec5SMitch Phillips 
1321184ec5SMitch Phillips   *Ptr = 0x0;
1421184ec5SMitch Phillips 
1521184ec5SMitch Phillips   delete Ptr;
1621184ec5SMitch Phillips   volatile char x = *Ptr;
1721184ec5SMitch Phillips   return 0;
1821184ec5SMitch Phillips }
19