]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/testsuite/gcc.dg/torture/pr47917.c
Remove obsolete Solaris 9 support
[thirdparty/gcc.git] / gcc / testsuite / gcc.dg / torture / pr47917.c
CommitLineData
bf3b3396
SE
1/* { dg-do run } */
2/* { dg-options "-std=c99" } */
ea61eea7 3/* { dg-options "-std=gnu99" { target *-*-hpux* } } */
5e4119ea 4/* { dg-additional-options "-D__USE_MINGW_ANSI_STDIO=1" { target *-*-mingw* } } */
bbcfbc63 5/* { dg-xfail-run-if "no C99 snprintf function" { *-*-hpux10* } } */
bf3b3396
SE
6/* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } } */
7
ba3ceb2d
JJ
8/* PR middle-end/47917 */
9
e560509f 10#include <stdio.h>
ba3ceb2d
JJ
11extern int memcmp (const void *, const void *, __SIZE_TYPE__);
12extern void abort (void);
13
14char buf1[6], buf2[6], buf3[4], buf4[4];
15int i;
16
17int
18foo (void)
19{
20 int ret = snprintf (buf1, sizeof buf1, "abcde");
21 ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
22 ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
23 ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 4096;
24 return ret;
25}
26
27int
28main (void)
29{
30 if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
31 abort ();
32 if (memcmp (buf1, "abcde", 6) != 0
33 || memcmp (buf2, "abcde", 6) != 0
34 || memcmp (buf3, "abc", 4) != 0
35 || memcmp (buf4, "def", 4) != 0
36 || i != 2)
37 abort ();
38 return 0;
39}