diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-06-25 11:13:44 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2008-06-25 11:13:44 +0000 |
commit | d2864a71b9562625502b78ea533df09a5ed11c15 (patch) | |
tree | ece01c7290f7172ceb9d98a3f064935a89dc9b09 /gcc/tree-ssa-structalias.c | |
parent | d2a3be90c30cefcce0e47267bf6a6d506e1ff93c (diff) | |
download | gcc-d2864a71b9562625502b78ea533df09a5ed11c15.tar.gz |
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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@137104 138bc75d-0d04-0410-961f-82ee72b054a4
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 338e190d4c8..052903da76b 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. */ |