This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR testsuite/32471 when INT_MAX is not 0x7fffffff


   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;
 }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]