1 /* PR middle-end/79496 - call to snprintf with non-zero size eliminated
2 with -Wformat-truncation=2
3 { dg-do compile }
4 { dg-options "-O2 -Wall -Wformat-truncation=2 -fprintf-return-value -fdump-tree-optimized" } */
5
6 char d[2];
7
test_cst(unsigned n)8 int test_cst (unsigned n)
9 {
10 if (1 < n)
11 n = 0;
12
13 return __builtin_snprintf (d, n, "%d", 1);
14 }
15
test_var(char * d,unsigned n)16 int test_var (char *d, unsigned n)
17 {
18 if (2 < n)
19 n = 0;
20
21 return __builtin_snprintf (d, n, "%i", 1);
22 }
23
24 /* { dg-final { scan-tree-dump-times "snprintf" 2 "optimized"} } */
25