xref: /aosp_15_r20/external/compiler-rt/test/ubsan/TestCases/Misc/vla.c (revision 7c3d14c8b49c529e04be81a3ce6f5cc23712e4c6)
1 // RUN: %clang -fsanitize=vla-bound %s -O3 -o %t
2 // RUN: %run %t 2>&1 | FileCheck %s --check-prefix=CHECK-MINUS-ONE
3 // RUN: %run %t a 2>&1 | FileCheck %s --check-prefix=CHECK-ZERO
4 // RUN: %run %t a b
5 
main(int argc,char ** argv)6 int main(int argc, char **argv) {
7   // CHECK-MINUS-ONE: vla.c:9:11: runtime error: variable length array bound evaluates to non-positive value -1
8   // CHECK-ZERO: vla.c:9:11: runtime error: variable length array bound evaluates to non-positive value 0
9   int arr[argc - 2];
10   return 0;
11 }
12