1 /* PR middle-end/47917 */
2 /* { dg-do compile } */
3 /* { dg-options "-O2 -fdump-tree-optimized" } */
5 extern int snprintf (char *, __SIZE_TYPE__
, const char *, ...);
6 extern int memcmp (const void *, const void *, __SIZE_TYPE__
);
7 extern void abort (void);
9 char buf1
[6], buf2
[6], buf3
[4], buf4
[4];
15 int ret
= snprintf (buf1
, sizeof buf1
, "abcde");
16 ret
+= snprintf (buf2
, sizeof buf2
, "abcdef") * 16;
17 ret
+= snprintf (buf3
, sizeof buf3
, "%s", i
++ < 6 ? "abc" : "def") * 256;
18 ret
+= snprintf (buf4
, sizeof buf4
, "%s", i
++ > 10 ? "abcde" : "defgh") * 4096;
25 if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
27 if (memcmp (buf1
, "abcde", 6) != 0
28 || memcmp (buf2
, "abcde", 6) != 0
29 || memcmp (buf3
, "abc", 4) != 0
30 || memcmp (buf4
, "def", 4) != 0
36 /* { dg-final { scan-tree-dump-times "snprintf" 2 "optimized" } } */
37 /* { dg-final { scan-tree-dump-times "sprintf" 0 "optimized" } } */