diff --git a/src/Math/Matrix3.h b/src/Math/Matrix3.h index 344f55d86..579610d70 100644 --- a/src/Math/Matrix3.h +++ b/src/Math/Matrix3.h @@ -244,7 +244,13 @@ template class Matrix3: public Matrix<3, T> { * @todo extract 2x2 matrix and multiply directly? (benchmark that) */ inline Vector2 transformVector(const Vector2& vector) const { + /* Workaround for GCC 4.4 strict-aliasing fascism */ + #ifndef CORRADE_GCC44_COMPATIBILITY return ((*this)*Vector3(vector, T(0))).xy(); + #else + const auto v = (*this)*Vector3(vector, T(0)); + return v.xy(); + #endif } /** @@ -257,7 +263,13 @@ template class Matrix3: public Matrix<3, T> { * @see DualComplex::transformPoint(), Matrix4::transformPoint() */ inline Vector2 transformPoint(const Vector2& vector) const { + /* Workaround for GCC 4.4 strict-aliasing fascism */ + #ifndef CORRADE_GCC44_COMPATIBILITY return ((*this)*Vector3(vector, T(1))).xy(); + #else + const auto v = (*this)*Vector3(vector, T(1)); + return v.xy(); + #endif } MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(3, 3, Matrix3) diff --git a/src/Math/Matrix4.h b/src/Math/Matrix4.h index 7a72d9ec3..2346b2e77 100644 --- a/src/Math/Matrix4.h +++ b/src/Math/Matrix4.h @@ -401,7 +401,13 @@ template class Matrix4: public Matrix<4, T> { * @todo extract 3x3 matrix and multiply directly? (benchmark that) */ inline Vector3 transformVector(const Vector3& vector) const { + /* Workaround for GCC 4.4 strict-aliasing fascism */ + #ifndef CORRADE_GCC44_COMPATIBILITY return ((*this)*Vector4(vector, T(0))).xyz(); + #else + const auto v = (*this)*Vector4(vector, T(0)); + return v.xyz(); + #endif } /** @@ -414,7 +420,13 @@ template class Matrix4: public Matrix<4, T> { * @see DualQuaternion::transformPoint(), Matrix3::transformPoint() */ inline Vector3 transformPoint(const Vector3& vector) const { + /* Workaround for GCC 4.4 strict-aliasing fascism */ + #ifndef CORRADE_GCC44_COMPATIBILITY return ((*this)*Vector4(vector, T(1))).xyz(); + #else + const auto v = (*this)*Vector4(vector, T(1)); + return v.xyz(); + #endif } MAGNUM_RECTANGULARMATRIX_SUBCLASS_IMPLEMENTATION(4, 4, Matrix4)