[build] Disable strict-overflow check on gcc

This flag generates false positives, since gcc inlines functions and
propagates constants, and then applies the check.

Drive-by: Refactor the checks that triggered the error to avoid
explicit casts.

R=jochen@chromium.org, machenbach@chromium.org
BUG=v8:6341

Change-Id: I86aebf402cbd2502ef17622a000a5bb777fd4b43
Reviewed-on: https://chromium-review.googlesource.com/494474
Reviewed-by: Michael Achenbach <machenbach@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Commit-Queue: Clemens Hammacher <clemensh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45096}
This commit is contained in:
Clemens Hammacher 2017-05-04 14:59:38 +02:00 committed by Commit Bot
parent 00d1e2cf76
commit 6548f76c92
3 changed files with 18 additions and 3 deletions

View File

@ -480,6 +480,15 @@ config("toolchain") {
"/wd4800", # Forcing value to bool.
]
}
if (!is_clang && !is_win) {
cflags += [
# Disable gcc warnings for optimizations based on the assumption that
# signed overflow does not occur. Generates false positives (see
# http://crbug.com/v8/6341).
"-Wno-strict-overflow",
]
}
}
###############################################################################

View File

@ -780,6 +780,12 @@
# Don't warn about unrecognized command line option.
'-Wno-gnu-zero-variadic-macro-arguments',
],
'cflags' : [
# Disable gcc warnings for optimizations based on the assumption
# that signed overflow does not occur. Generates false positives
# (see http://crbug.com/v8/6341).
"-Wno-strict-overflow",
],
}],
[ 'clang==1 and (v8_target_arch=="x64" or v8_target_arch=="arm64" \
or v8_target_arch=="mips64el")', {

View File

@ -34,9 +34,9 @@ class Vector {
// Returns a vector using the same backing storage as this one,
// spanning from and including 'from', to but not including 'to'.
Vector<T> SubVector(int from, int to) const {
DCHECK(0 <= from);
SLOW_DCHECK(from <= to);
SLOW_DCHECK(static_cast<unsigned>(to) <= static_cast<unsigned>(length_));
DCHECK_LE(0, from);
DCHECK_LE(from, to);
DCHECK_LE(to, length_);
return Vector<T>(start() + from, to - from);
}