xref: /aosp_15_r20/external/compiler-rt/test/asan/TestCases/use-after-scope-loop-bug.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 // FIXME: @llvm.lifetime.* are not emitted for x.
5*7c3d14c8STreehugger Robot // XFAIL: *
6*7c3d14c8STreehugger Robot 
7*7c3d14c8STreehugger Robot int *p;
8*7c3d14c8STreehugger Robot 
main()9*7c3d14c8STreehugger Robot int main() {
10*7c3d14c8STreehugger Robot   // Variable goes in and out of scope.
11*7c3d14c8STreehugger Robot   for (int i = 0; i < 3; ++i) {
12*7c3d14c8STreehugger Robot     int x[3] = {i, i, i};
13*7c3d14c8STreehugger Robot     p = x + i;
14*7c3d14c8STreehugger Robot   }
15*7c3d14c8STreehugger Robot   return *p;  // BOOM
16*7c3d14c8STreehugger Robot }
17