diff options
author | Richard Guenther <rguenther@suse.de> | 2008-06-25 11:13:44 +0000 |
---|---|---|
committer | Richard Biener <rguenth@gcc.gnu.org> | 2008-06-25 11:13:44 +0000 |
commit | 185ab3b677bf383dc804bc52bc58f24e67a16825 (patch) | |
tree | ece01c7290f7172ceb9d98a3f064935a89dc9b09 /gcc/tree-ssa-structalias.c | |
parent | 8ef834ca4defdd75ad6b9bb329a95eb5cf55823b (diff) | |
download | gcc-185ab3b677bf383dc804bc52bc58f24e67a16825.zip gcc-185ab3b677bf383dc804bc52bc58f24e67a16825.tar.gz gcc-185ab3b677bf383dc804bc52bc58f24e67a16825.tar.bz2 |
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
Diffstat (limited to 'gcc/tree-ssa-structalias.c')
-rw-r--r-- | gcc/tree-ssa-structalias.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/gcc/tree-ssa-structalias.c b/gcc/tree-ssa-structalias.c index 338e190..052903d 100644 --- a/gcc/tree-ssa-structalias.c +++ b/gcc/tree-ssa-structalias.c @@ -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. */ |