xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/use-after-scope-loop.cc (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1*7c3d14c8STreehugger Robot // RUN: %clangxx_asan -O1 -fsanitize-address-use-after-scope %s -o %t && \
2*7c3d14c8STreehugger Robot // RUN:     not %run %t 2>&1 | FileCheck %s
3*7c3d14c8STreehugger Robot 
4*7c3d14c8STreehugger Robot int *p[3];
5*7c3d14c8STreehugger Robot 
main()6*7c3d14c8STreehugger Robot int main() {
7*7c3d14c8STreehugger Robot   for (int i = 0; i < 3; i++) {
8*7c3d14c8STreehugger Robot     int x;
9*7c3d14c8STreehugger Robot     p[i] = &x;
10*7c3d14c8STreehugger Robot   }
11*7c3d14c8STreehugger Robot   return **p;  // BOOM
12*7c3d14c8STreehugger Robot   // CHECK: ERROR: AddressSanitizer: stack-use-after-scope
13*7c3d14c8STreehugger Robot   // CHECK: #0 0x{{.*}} in main {{.*}}.cc:[[@LINE-2]]
14*7c3d14c8STreehugger Robot }
15