Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / compiler-rt / test / gwp_asan / use_after_free.cpp
blob912f8f7fbc90f6a8626f36f6a1010a707f8308d8
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 = reinterpret_cast<char *>(malloc(10));
13 for (unsigned i = 0; i < 10; ++i) {
14 *(Ptr + i) = 0x0;
17 free(Ptr);
18 volatile char x = *Ptr;
19 return 0;