1 /* PR tree-optimization/78969 - bogus snprintf truncation warning due to
4 { dg-options "-O2 -Wall -Wformat-truncation=2" } */
6 typedef __SIZE_TYPE__
size_t;
8 extern int snprintf (char*, size_t, const char*, ...);
11 void f (unsigned j
, char *p
)
16 snprintf (p
, 4, "%3u", j
);
19 void g (unsigned j
, char *p
)
24 snprintf (p
, 4, "%3u", j
); // { dg-bogus "-Wformat-truncation" }
28 void pr78969_c4 (char * p
/* NNN\0" */)
30 for (int idx
= 0; idx
< 1000; idx
++) {
31 // guaranteed to be in [0-999] range
32 snprintf (p
, 4, "%d", idx
); // { dg-bogus "-Wformat-truncation" }
41 void pr78969_c12 (unsigned i
)
43 if (i
>= 1000 && i
< 10000)
44 snprintf (d
, 4, "%3d", i
/ 10); // { dg-bogus "-Wformat-truncation" }