public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Rask Ingemann Lambertsen <rask@sygehus.dk>
To: gcc-patches@gcc.gnu.org
Subject: [PATCH] Fix PR testsuite/32471 when INT_MAX is not 0x7fffffff
Date: Fri, 27 Jul 2007 16:55:00 -0000	[thread overview]
Message-ID: <20070727155625.GL3001@sygehus.dk> (raw)

   This patch fixes the test cases for PR 30364 which test overflow
behaviour of integers. With "gcc version 4.1.2 20061115 (prerelease) (Debian
4.1.1-21)", pr30364-1.c still fails at -O2, which is what bug 30364 was
opened for. For mainline x86_64-unknown-linux-gnu, there are no changes in
test results (they still all pass) while for m32c-unknown-elf, they now all
pass where they all used to fail (for a total of 36 FAILs).

   Ok for trunk?

:ADDPATCH testsuite:

2007-07-27  Rask Ingemann Lambertsen  <rask@sygehus.dk>

	PR testsuite/32471
	gcc.dg/torture/pr30364-1.c (f)(main): Use INT_MAX instead of
	assuming it is 0x7ffffffff.
	gcc.dg/torture/pr30364-2.c (f)(main): Likewise.
	gcc.dg/torture/pr30364-3.c (f)(main): Likewise.

Index: gcc.dg/torture/pr30364-1.c
===================================================================
--- gcc.dg/torture/pr30364-1.c	(revision 126653)
+++ gcc.dg/torture/pr30364-1.c	(working copy)
@@ -1,19 +1,20 @@
 /* { dg-do run } */
 
+#include <limits.h>
 extern void abort (void);
 
 int f(int a, int b)
 {
-  if (a > 0x7FFFFFF0) return 0;
-  if (b > 0x7FFFFFF0) return 0;
+  if (a > INT_MAX - 15) return 0;
+  if (b > INT_MAX - 15) return 0;
 
   int c = (a - 20) + (b - 20);
-  return c > 0x7FFFFFF0;
+  return c > INT_MAX - 15;
 }
 
 int main()
 {
-  if (f (0x7FFFFFF0, 41) != 1)
+  if (f (INT_MAX - 15, 41) != 1)
     abort ();
   return 0;
 }
Index: gcc.dg/torture/pr30364-2.c
===================================================================
--- gcc.dg/torture/pr30364-2.c	(revision 126653)
+++ gcc.dg/torture/pr30364-2.c	(working copy)
@@ -1,19 +1,20 @@
 /* { dg-do run } */
 
+#include <limits.h>
 extern void abort (void);
 
 int f(unsigned int a, unsigned int b)
 {
-  if (a > 0x7FFFFFF0) return 0;
-  if (b > 0x7FFFFFF0) return 0;
+  if (a > INT_MAX - 15) return 0;
+  if (b > INT_MAX - 15) return 0;
 
   int c = (a - 20) + (b - 20);
-  return c > 0x7FFFFFF0;
+  return c > INT_MAX - 15;
 }
 
 int main()
 {
-  if (f (0x7FFFFFF0, 41) != 1)
+  if (f (INT_MAX - 15, 41) != 1)
     abort ();
   return 0;
 }
Index: gcc.dg/torture/pr30364-3.c
===================================================================
--- gcc.dg/torture/pr30364-3.c	(revision 126653)
+++ gcc.dg/torture/pr30364-3.c	(working copy)
@@ -1,20 +1,21 @@
 /* { dg-do run } */
 /* { dg-options "-fwrapv" } */
 
+#include <limits.h>
 extern void abort (void);
 
 int f(int a, int b)
 {
-  if (a > 0x7FFFFFF0) return 0;
-  if (b > 0x7FFFFFF0) return 0;
+  if (a > INT_MAX - 15) return 0;
+  if (b > INT_MAX - 15) return 0;
 
   int c = (a - 20) + (b - 20);
-  return c > 0x7FFFFFF0;
+  return c > INT_MAX - 15;
 }
 
 int main()
 {
-  if (f (0x7FFFFFF0, 41) != 1)
+  if (f (INT_MAX - 15, 41) != 1)
     abort ();
   return 0;
 }

             reply	other threads:[~2007-07-27 15:56 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-27 16:55 Rask Ingemann Lambertsen [this message]
2007-07-27 20:10 ` Janis Johnson

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=20070727155625.GL3001@sygehus.dk \
    --to=rask@sygehus.dk \
    --cc=gcc-patches@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).