view gcc/testsuite/g++.dg/ubsan/vla-1.C @ 145:1830386684a0

gcc-9.2.0
author anatofuz
date Thu, 13 Feb 2020 11:34:05 +0900
parents 04ced10e8804
children
line wrap: on
line source

// { dg-do run }
// { dg-options "-Wno-vla -Wno-stringop-overflow -fsanitize=undefined" }
// { dg-output "index 1 out of bounds" }

void f(int i)
{
  /* The following creates an array of char[4] on the stack and
     the initialization triggers a -Wstringop-overflow with LTO
     (or when the function is inlined into the called, such as
     with -fwhole-program).  See PR91258.  The warning is
     suppressed above.  */
  int ar[i] = { 42, 24 };
}

int main()
{
  f(1);
}