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

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
This commit is contained in:
Richard Guenther 2008-06-25 11:13:44 +00:00 committed by Richard Biener
parent 8ef834ca4d
commit 185ab3b677
4 changed files with 35 additions and 4 deletions

View 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.

View 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.

View File

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

View 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. */