aboutsummaryrefslogtreecommitdiff
path: root/gcc
diff options
context:
space:
mode:
authorMarkus Trippelsdorf <markus@trippelsdorf.de>2016-12-01 14:59:03 +0000
committerMarkus Trippelsdorf <trippels@gcc.gnu.org>2016-12-01 14:59:03 +0000
commit56e1a4d7127256bb3f476a6d93954b1948b03985 (patch)
treee7fa9f01ce547c150383e768b27b5d36e7e02f26 /gcc
parentbe5ddbb86fbc4d7651f4c748528ecab6d31cd035 (diff)
downloadgcc-56e1a4d7127256bb3f476a6d93954b1948b03985.zip
gcc-56e1a4d7127256bb3f476a6d93954b1948b03985.tar.gz
gcc-56e1a4d7127256bb3f476a6d93954b1948b03985.tar.bz2
Fix PR tree-optimization/78598 - tree-ssa-loop-prefetch.c:835:16: runtime error: signed integer overflow
Using bootstrap-ubsan gcc to build mplayer shows: tree-ssa-loop-prefetch.c:835:16: runtime error: signed integer overflow: 288230376151711743 * 64 cannot be represented in type 'long int' Here signed und unsigned integers are mixed in a division resulting in bogus values: (-83 + 64ULL -1) / 64ULL) == 288230376151711743 Fixed by casting the unsigned parameter to signed. PR tree-optimization/78598 * tree-ssa-loop-prefetch.c (ddown): Cast to signed to avoid overflows. From-SVN: r243113
Diffstat (limited to 'gcc')
-rw-r--r--gcc/ChangeLog6
-rw-r--r--gcc/tree-ssa-loop-prefetch.c4
2 files changed, 8 insertions, 2 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index b90cbc6..17e9831 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -1,5 +1,11 @@
2016-12-01 Markus Trippelsdorf <markus@trippelsdorf.de>
+ PR tree-optimization/78598
+ * tree-ssa-loop-prefetch.c (ddown): Cast to signed to avoid
+ overflows.
+
+2016-12-01 Markus Trippelsdorf <markus@trippelsdorf.de>
+
PR rtl-optimization/78596
* combine.c (simplify_comparison): Cast to unsigned to avoid
left shifting of negative value.
diff --git a/gcc/tree-ssa-loop-prefetch.c b/gcc/tree-ssa-loop-prefetch.c
index 0a2ee5e..ead2543 100644
--- a/gcc/tree-ssa-loop-prefetch.c
+++ b/gcc/tree-ssa-loop-prefetch.c
@@ -700,9 +700,9 @@ ddown (HOST_WIDE_INT x, unsigned HOST_WIDE_INT by)
gcc_assert (by > 0);
if (x >= 0)
- return x / by;
+ return x / (HOST_WIDE_INT) by;
else
- return (x + by - 1) / by;
+ return (x + (HOST_WIDE_INT) by - 1) / (HOST_WIDE_INT) by;
}
/* Given a CACHE_LINE_SIZE and two inductive memory references