This patch moves gcc.c-torture/execute/pr47917.c to
gcc.dg/torture/pr47917.c so that I can use dg-* directives in the test
and then adds xfails for HP-UX.  On HP-UX 10.* there is no snprintf
function so the test does not compile.  On HP-UX 11.[012]*, there is a
snprintf function but it is not C99 compliant so the test compiles but
fails when it is run.  On HP-UX 11.31 it is possible to get the correct
behaviour and I will be submitting a seperate patch to deal with that.

The problem is that on HP-UX snprintf is returning -1 for buffer overflow
instead of returning the number of bytes that would have been output if the
buffer hadn't filled up.

Dave, can you verify this fix on HP-UX 10.*?  I don't have any HP-UX
10.* systems anymore.  Tested on IA64 and PA HP-UX 11.11 and 11.23.

Steve Ellcey
s...@cup.hp.com


2011-03-23  Steve Ellcey  <s...@cup.hp.com>

        PR target/48209
        * gcc.c-torture/execute/pr47917.c: Move this...
        * gcc.dg/torture/pr47917.c: to here and add xfails.

Index: gcc.c-torture/execute/pr47917.c
===================================================================
--- gcc.c-torture/execute/pr47917.c     (revision 171338)
+++ gcc.c-torture/execute/pr47917.c     (working copy)
@@ -1,32 +0,0 @@
-/* PR middle-end/47917 */
-
-extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);
-extern int memcmp (const void *, const void *, __SIZE_TYPE__);
-extern void abort (void);
-
-char buf1[6], buf2[6], buf3[4], buf4[4];
-int i;
-
-int
-foo (void)
-{
-  int ret = snprintf (buf1, sizeof buf1, "abcde");
-  ret += snprintf (buf2, sizeof buf2, "abcdef") * 16;
-  ret += snprintf (buf3, sizeof buf3, "%s", i++ < 6 ? "abc" : "def") * 256;
-  ret += snprintf (buf4, sizeof buf4, "%s", i++ > 10 ? "abcde" : "defgh") * 
4096;
-  return ret;
-}
-
-int
-main (void)
-{
-  if (foo () != 5 + 6 * 16 + 3 * 256 + 5 * 4096)
-    abort ();
-  if (memcmp (buf1, "abcde", 6) != 0
-      || memcmp (buf2, "abcde", 6) != 0
-      || memcmp (buf3, "abc", 4) != 0
-      || memcmp (buf4, "def", 4) != 0
-      || i != 2)
-    abort ();
-  return 0;
-}
Index: gcc.dg/torture/pr47917.c
===================================================================
--- gcc.dg/torture/pr47917.c    (revision 171278)
+++ gcc.dg/torture/pr47917.c    (working copy)
@@ -1,3 +1,8 @@
+/* { dg-do run } */
+/* { dg-options "-std=c99" } */
+/* { dg-xfail-if "no C99 snprintf function" { *-*-hpux10* } } */
+/* { dg-xfail-run-if "non-conforming C99 snprintf" { *-*-hpux11.[012]* } } */
+
 /* PR middle-end/47917 */
 
 extern int snprintf (char *, __SIZE_TYPE__, const char *, ...);

Reply via email to