aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.dg/tree-ssa/builtin-sprintf-warn-27.c
blob: 8188dd8005f98c0b5400f90c648d47c4d6b76bba (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
/* PR middle-end/100325 - missing warning with -O0 on sprintf overflow with
   pointer plus offset
   { dg-do compile }
   { dg-options "-O0 -Wall" } */

#define S(n) (&"0123456789"[10 - n])

extern int sprintf (char*, const char*, ...);

char d[10];

void nowarn_d10_s9 ()
{
  sprintf (d, "%s", S (9));     // { dg-bogus "-Wformat-overflow" }
}

void warn_d10_s10 ()
{
  sprintf (d, "%s", S (10));    // { dg-warning "-Wformat-overflow" }
}