Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Unified Diff: src/compiler/operator.h

Issue 847093002: Make UBSan happy about OpParameter casts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: One more instance. Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/operator.h
diff --git a/src/compiler/operator.h b/src/compiler/operator.h
index fb144ce896a4355a738371de31c9177a1e7f22ab..09a49443ea745c3c748674a8a2e028d51f150b61 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<T>* that = static_cast<const Operator1<T>*>(other);
+ const Operator1<T>* that = reinterpret_cast<const Operator1<T>*>(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 <typename T>
inline T const& OpParameter(const Operator* op) {
- return static_cast<const Operator1<T>*>(op)->parameter();
+ return reinterpret_cast<const Operator1<T>*>(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<const Operator1<float, base::bit_equal_to<float>,
- base::bit_hash<float>>*>(op)->parameter();
+ return reinterpret_cast<const Operator1<float, base::bit_equal_to<float>,
+ base::bit_hash<float>>*>(op)
+ ->parameter();
}
template <>
inline double const& OpParameter(const Operator* op) {
- return static_cast<const Operator1<double, base::bit_equal_to<double>,
- base::bit_hash<double>>*>(op)->parameter();
+ return reinterpret_cast<const Operator1<double, base::bit_equal_to<double>,
+ base::bit_hash<double>>*>(op)
+ ->parameter();
}
} // namespace compiler
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698