From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11419 invoked by alias); 23 Mar 2011 16:22:45 -0000 Received: (qmail 11311 invoked by uid 22791); 23 Mar 2011 16:22:41 -0000 X-SWARE-Spam-Status: No, hits=-1.9 required=5.0 tests=AWL,BAYES_00,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from g4t0017.houston.hp.com (HELO g4t0017.houston.hp.com) (15.201.24.20) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 23 Mar 2011 16:22:35 +0000 Received: from g4t0018.houston.hp.com (g4t0018.houston.hp.com [16.234.32.27]) by g4t0017.houston.hp.com (Postfix) with ESMTP id C03F538A1E; Wed, 23 Mar 2011 16:22:34 +0000 (UTC) Received: from lucas.cup.hp.com (lucas.cup.hp.com [15.244.97.116]) by g4t0018.houston.hp.com (Postfix) with ESMTP id 60B41102E6; Wed, 23 Mar 2011 16:22:34 +0000 (UTC) Received: (from sje@localhost) by lucas.cup.hp.com (8.11.1 (PHNE_35485)/8.11.1) id p2NGMXK17504; Wed, 23 Mar 2011 09:22:33 -0700 (PDT) Date: Wed, 23 Mar 2011 16:22:00 -0000 From: Steve Ellcey Message-Id: <201103231622.p2NGMXK17504@lucas.cup.hp.com> To: gcc-patches@gcc.gnu.org Subject: [patch, hpux, testsuite] XFAIL pr47917.c for non-conforming snprintf Cc: danglin@gcc.gnu.org, jakub@gcc.gnu.org Reply-to: sje@cup.hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-03/txt/msg01511.txt.bz2 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 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 *, ...);