99 lines
3.5 KiB
Diff
99 lines
3.5 KiB
Diff
|
From aab2cc3a20af9ebe9ddb8dfd15089f131f95817f Mon Sep 17 00:00:00 2001
|
||
|
From: Tomas Popela <tomas.popela@gmail.com>
|
||
|
Date: Fri, 20 Oct 2017 14:06:42 +0200
|
||
|
Subject: [PATCH] Fix the build of base/numerics with GCC
|
||
|
|
||
|
Initialize the uninitialized variables where the build is failing.
|
||
|
|
||
|
BUG=776705
|
||
|
|
||
|
Change-Id: I5782e18086a752b3676f8738930bf0553f3f97ad
|
||
|
---
|
||
|
base/numerics/checked_math_impl.h | 6 +++---
|
||
|
base/numerics/clamped_math_impl.h | 10 +++++-----
|
||
|
2 files changed, 8 insertions(+), 8 deletions(-)
|
||
|
|
||
|
diff --git a/base/numerics/checked_math_impl.h b/base/numerics/checked_math_impl.h
|
||
|
index 2926b37b5e..e083389ebf 100644
|
||
|
--- a/base/numerics/checked_math_impl.h
|
||
|
+++ b/base/numerics/checked_math_impl.h
|
||
|
@@ -67,7 +67,7 @@ struct CheckedAddOp<T,
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
- Promotion presult;
|
||
|
+ Promotion presult = {};
|
||
|
bool is_valid = true;
|
||
|
if (IsIntegerArithmeticSafe<Promotion, T, U>::value) {
|
||
|
presult = static_cast<Promotion>(x) + static_cast<Promotion>(y);
|
||
|
@@ -127,7 +127,7 @@ struct CheckedSubOp<T,
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
- Promotion presult;
|
||
|
+ Promotion presult = {};
|
||
|
bool is_valid = true;
|
||
|
if (IsIntegerArithmeticSafe<Promotion, T, U>::value) {
|
||
|
presult = static_cast<Promotion>(x) - static_cast<Promotion>(y);
|
||
|
@@ -183,7 +183,7 @@ struct CheckedMulOp<T,
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
- Promotion presult;
|
||
|
+ Promotion presult = {};
|
||
|
bool is_valid = true;
|
||
|
if (CheckedMulFastOp<Promotion, Promotion>::is_supported) {
|
||
|
// The fast op may be available with the promoted type.
|
||
|
diff --git a/base/numerics/clamped_math_impl.h b/base/numerics/clamped_math_impl.h
|
||
|
index 7b5e4346f2..303a7e945a 100644
|
||
|
--- a/base/numerics/clamped_math_impl.h
|
||
|
+++ b/base/numerics/clamped_math_impl.h
|
||
|
@@ -87,7 +87,7 @@ struct ClampedAddOp<T,
|
||
|
"The saturation result cannot be determined from the "
|
||
|
"provided types.");
|
||
|
const V saturated = CommonMaxOrMin<V>(IsValueNegative(y));
|
||
|
- V result;
|
||
|
+ V result = {};
|
||
|
return BASE_NUMERICS_LIKELY((CheckedAddOp<T, U>::Do(x, y, &result)))
|
||
|
? result
|
||
|
: saturated;
|
||
|
@@ -114,7 +114,7 @@ struct ClampedSubOp<T,
|
||
|
"The saturation result cannot be determined from the "
|
||
|
"provided types.");
|
||
|
const V saturated = CommonMaxOrMin<V>(!IsValueNegative(y));
|
||
|
- V result;
|
||
|
+ V result = {};
|
||
|
return BASE_NUMERICS_LIKELY((CheckedSubOp<T, U>::Do(x, y, &result)))
|
||
|
? result
|
||
|
: saturated;
|
||
|
@@ -136,7 +136,7 @@ struct ClampedMulOp<T,
|
||
|
if (ClampedMulFastOp<T, U>::is_supported)
|
||
|
return ClampedMulFastOp<T, U>::template Do<V>(x, y);
|
||
|
|
||
|
- V result;
|
||
|
+ V result = {};
|
||
|
const V saturated =
|
||
|
CommonMaxOrMin<V>(IsValueNegative(x) ^ IsValueNegative(y));
|
||
|
return BASE_NUMERICS_LIKELY((CheckedMulOp<T, U>::Do(x, y, &result)))
|
||
|
@@ -156,7 +156,7 @@ struct ClampedDivOp<T,
|
||
|
using result_type = typename MaxExponentPromotion<T, U>::type;
|
||
|
template <typename V = result_type>
|
||
|
static constexpr V Do(T x, U y) {
|
||
|
- V result;
|
||
|
+ V result = {};
|
||
|
if (BASE_NUMERICS_LIKELY((CheckedDivOp<T, U>::Do(x, y, &result))))
|
||
|
return result;
|
||
|
// Saturation goes to max, min, or NaN (if x is zero).
|
||
|
@@ -176,7 +176,7 @@ struct ClampedModOp<T,
|
||
|
using result_type = typename MaxExponentPromotion<T, U>::type;
|
||
|
template <typename V = result_type>
|
||
|
static constexpr V Do(T x, U y) {
|
||
|
- V result;
|
||
|
+ V result = {};
|
||
|
return BASE_NUMERICS_LIKELY((CheckedModOp<T, U>::Do(x, y, &result)))
|
||
|
? result
|
||
|
: x;
|
||
|
--
|
||
|
2.14.2
|
||
|
|