public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Steve Ellcey <sje@cup.hp.com>
To: gcc-patches@gcc.gnu.org
Cc: danglin@gcc.gnu.org, jakub@gcc.gnu.org
Subject: [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf
Date: Wed, 23 Mar 2011 16:22:00 -0000	[thread overview]
Message-ID: <201103231622.p2NGMXK17504@lucas.cup.hp.com> (raw)

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
sje@cup.hp.com


2011-03-23  Steve Ellcey  <sje@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	other threads:[~2011-03-23 16:22 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-03-23 16:22 Steve Ellcey [this message]
2011-03-23 20:34 ` John David Anglin
2011-03-23 20:44   ` Steve Ellcey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=201103231622.p2NGMXK17504@lucas.cup.hp.com \
    --to=sje@cup.hp.com \
    --cc=danglin@gcc.gnu.org \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jakub@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).