Debian Codegraph @

gcc/testsuite/g++.dg/ubsan/vla-1.C

raw
1 // { dg-do run }
2 // { dg-options "-Wno-vla -Wno-stringop-overflow -fsanitize=undefined" }
3 // { dg-output "index 1 out of bounds" }
4
5 void f(int i)
6 {
7 /* The following creates an array of char[4] on the stack and
8 the initialization triggers a -Wstringop-overflow with LTO
9 (or when the function is inlined into the called, such as
10 with -fwhole-program). See PR91258. The warning is
11 suppressed above. */
12 int ar[i] = { 42, 24 };
13 }
14
15 int main()
16 {
17 f(1);
18 }