Debian Codegraph @

gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-27.c

raw
1 /* PR middle-end/100325 - missing warning with -O0 on sprintf overflow with
2 pointer plus offset
3 { dg-do compile }
4 { dg-options "-O0 -Wall" } */
5
6 #define S(n) (&"0123456789"[10 - n])
7
8 extern int sprintf (char*, const char*, ...);
9
10 char d[10];
11
12 void nowarn_d10_s9 ()
13 {
14 sprintf (d, "%s", S (9)); // { dg-bogus "-Wformat-overflow" }
15 }
16
17 void warn_d10_s10 ()
18 {
19 sprintf (d, "%s", S (10)); // { dg-warning "-Wformat-overflow" }
20 }