]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
tree-ssa-structalias.c (fieldoff_compare): Make sure to not overflow the result type.
authorRichard Guenther <rguenther@suse.de>
Wed, 25 Jun 2008 11:13:44 +0000 (11:13 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 25 Jun 2008 11:13:44 +0000 (11:13 +0000)
2008-06-25  Richard Guenther  <rguenther@suse.de>

* tree-ssa-structalias.c (fieldoff_compare): Make sure to
not overflow the result type.

* gcc.c-torture/compile/20080625-1.c: New testcase.

From-SVN: r137104

gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.c-torture/compile/20080625-1.c [new file with mode: 0644]
gcc/tree-ssa-structalias.c

index c22cbe718040b75b9cdbe9b41c421e33fc976cd1..2516b26bdef4e00327780253eb13d2c627ccb747 100644 (file)
@@ -1,3 +1,8 @@
+2008-06-25  Richard Guenther  <rguenther@suse.de>
+
+       * tree-ssa-structalias.c (fieldoff_compare): Make sure to
+       not overflow the result type.
+
 2008-06-25  Richard Guenther  <rguenther@suse.de>
 
        * tree-vn.c (vn_add): Handle TRUTH_*_EXPR.
index 20c6345f6d1118d673f3a2c3869efd015bed4aaf..6bcc8e70ead2e9cad5e9a765dfbffcfe934e98c1 100644 (file)
@@ -1,3 +1,7 @@
+2008-06-25  Richard Guenther  <rguenther@suse.de>
+
+       * gcc.c-torture/compile/20080625-1.c: New testcase.
+
 2008-06-25  Richard Guenther  <rguenther@suse.de>
 
        * g++.dg/torture/20080625-1.C: New testcase.
diff --git a/gcc/testsuite/gcc.c-torture/compile/20080625-1.c b/gcc/testsuite/gcc.c-torture/compile/20080625-1.c
new file mode 100644 (file)
index 0000000..f0900fd
--- /dev/null
@@ -0,0 +1,16 @@
+struct peakbufStruct {
+    unsigned int lnum [5000];
+    int lscan [5000][4000];
+    double lmz [5000][4000];
+    double lint [5000][4000];
+    int PeaksInBuf;
+    unsigned char freelists [350000];
+    unsigned char freelistl [5000];
+    unsigned int LastFreeL;
+} peakbuf;
+void foo(int);
+void findmzROI(int i, int *p_scan)
+{
+    foo(peakbuf.PeaksInBuf);
+    __builtin_memmove(p_scan, peakbuf.lscan[i], peakbuf.lnum[i]*sizeof(int));
+}
index 338e190d4c8fb6c6d8554c4b4a0dc7a88d76628f..052903da76be4954141502bbc88c83c59572ecf0 100644 (file)
@@ -3999,14 +3999,20 @@ fieldoff_compare (const void *pa, const void *pb)
 {
   const fieldoff_s *foa = (const fieldoff_s *)pa;
   const fieldoff_s *fob = (const fieldoff_s *)pb;
-  HOST_WIDE_INT foasize, fobsize;
+  unsigned HOST_WIDE_INT foasize, fobsize;
 
-  if (foa->offset != fob->offset)
-    return foa->offset - fob->offset;
+  if (foa->offset < fob->offset)
+    return -1;
+  else if (foa->offset > fob->offset)
+    return 1;
 
   foasize = TREE_INT_CST_LOW (foa->size);
   fobsize = TREE_INT_CST_LOW (fob->size);
-  return foasize - fobsize;
+  if (foasize < fobsize)
+    return - 1;
+  else if (foasize > fobsize)
+    return 1;
+  return 0;
 }
 
 /* Sort a fieldstack according to the field offset and sizes.  */