From f449ba96967fa12836755a37d2c4ee64c57532af Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 20 Nov 2012 01:11:01 +0100 Subject: [PATCH] GCC 4.4: fixed some strict-aliasing warnings. --- src/MeshTools/Clean.h | 3 ++- src/ResourceManager.h | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/MeshTools/Clean.h b/src/MeshTools/Clean.h index 09a68d58c..47dde00e7 100644 --- a/src/MeshTools/Clean.h +++ b/src/MeshTools/Clean.h @@ -105,7 +105,8 @@ template class Clean { class IndexHash { public: inline std::size_t operator()(const Math::Vector& data) const { - return *reinterpret_cast(Corrade::Utility::MurmurHash2()(reinterpret_cast(&data), sizeof(data)).byteArray()); + /* GCC 4.4 thinks reinterpret_cast will break strict aliasing, doing it with bit cast instead */ + return Corrade::Utility::bitCast(Corrade::Utility::MurmurHash2()(reinterpret_cast(&data), sizeof(data))); } }; diff --git a/src/ResourceManager.h b/src/ResourceManager.h index 48835fffc..fdef3867f 100644 --- a/src/ResourceManager.h +++ b/src/ResourceManager.h @@ -116,7 +116,8 @@ template class Resource; namespace Implementation { struct ResourceKeyHash { inline std::size_t operator()(ResourceKey key) const { - return *reinterpret_cast(key.byteArray()); + /* GCC 4.4 thinks reinterpret_cast will break strict aliasing, doing it with bit cast instead */ + return Corrade::Utility::bitCast(key); } };