Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / gwp_asan / use_after_deletea.cpp
blob576608685a022f181bf0666ece60254aad9ee104
1 // REQUIRES: gwp_asan
2 // RUN: %clangxx_gwp_asan %s -o %t
3 // RUN: %expect_crash %run %t 2>&1 | FileCheck %s
5 // CHECK: GWP-ASan detected a memory error
6 // CHECK: Use After Free at 0x{{[a-f0-9]+}} (0 bytes into a 10-byte allocation
8 #include <cstdlib>
10 int main() {
11 char *Ptr = new char[10];
13 for (unsigned i = 0; i < 10; ++i) {
14 *(Ptr + i) = 0x0;
17 delete[] Ptr;
18 volatile char x = *Ptr;
19 return 0;