brintos

brintos / llvm-project-archived public Read only

0
0
Text · 697 B · a2d5943 Raw
26 lines · cpp
1// This is the ASAN test of the same name ported to HWAsan.2 3// Test with "-O2" only to make sure inlining (leading to use-after-scope)4// happens. "always_inline" is not enough, as Clang doesn't emit5// llvm.lifetime intrinsics at -O0.6//7// RUN: %clangxx_hwasan -O2 %s -o %t && \8// RUN:     not %run %t 2>&1 | FileCheck %s9 10// REQUIRES: aarch64-target-arch || riscv64-target-arch11 12int *arr;13__attribute__((always_inline)) void inlined(int arg) {14  int x[5];15  for (int i = 0; i < arg; i++)16    x[i] = i;17  arr = x;18}19 20int main(int argc, char *argv[]) {21  inlined(argc);22  return arr[argc - 1]; // BOOM23  // CHECK: ERROR: HWAddressSanitizer: tag-mismatch24  // CHECK: Cause: stack tag-mismatch25}26