From c36b5ac6252ea71701c44a68819f5b96f79b91ed Mon Sep 17 00:00:00 2001 From: mstarzinger Date: Tue, 13 Jan 2015 05:38:41 -0800 Subject: [PATCH] Make UBSan happy about OpParameter casts. R=svenpanne@chromium.org BUG=chromium:448141 LOG=N Review URL: https://codereview.chromium.org/847093002 Cr-Commit-Position: refs/heads/master@{#26042} --- src/compiler/operator.h | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/compiler/operator.h b/src/compiler/operator.h index fb144ce..09a4944 100644 --- a/src/compiler/operator.h +++ b/src/compiler/operator.h @@ -143,7 +143,7 @@ class Operator1 : public Operator { bool Equals(const Operator* other) const FINAL { if (opcode() != other->opcode()) return false; - const Operator1* that = static_cast*>(other); + const Operator1* that = reinterpret_cast*>(other); return this->pred_(this->parameter(), that->parameter()); } size_t HashCode() const FINAL { @@ -169,21 +169,23 @@ class Operator1 : public Operator { // Helper to extract parameters from Operator1<*> operator. template inline T const& OpParameter(const Operator* op) { - return static_cast*>(op)->parameter(); + return reinterpret_cast*>(op)->parameter(); } // NOTE: We have to be careful to use the right equal/hash functions below, for // float/double we always use the ones operating on the bit level. template <> inline float const& OpParameter(const Operator* op) { - return static_cast, - base::bit_hash>*>(op)->parameter(); + return reinterpret_cast, + base::bit_hash>*>(op) + ->parameter(); } template <> inline double const& OpParameter(const Operator* op) { - return static_cast, - base::bit_hash>*>(op)->parameter(); + return reinterpret_cast, + base::bit_hash>*>(op) + ->parameter(); } } // namespace compiler -- 2.7.4