From dbd14b9e5b82d45159c8ec8c6b0e01fd8361160b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20Vondru=C5=A1?= Date: Tue, 20 Nov 2012 10:20:25 +0100 Subject: [PATCH] GCC 4.4: disabling strict-aliasing altogether. It seriously breaks RectangularMatrix::from() and related functions in subclasses and I don't have better solution for that yet. Hope newer GCCs fix this issue, because compiling with this option is a way to unoptimized hell. The breakage can be seen when Physics::AxisAlignedBox::applyTransformation() is called in loop from Physics::ObjectShapeGroup::setClean() (e.g. three AABBs in the group). Result is that the transformation doesn't get applied at all. I tried also these solutions without success: * Reimplementing from() to return (const) copy, so it doesn't alias original type (warnings suddenly disappear, but the problem persists). * Using __attribute__((__may_alias__)) on RectangularMatrix - doesn't help at all (even the warnings remain). * Using __attribute__((__may_alias__)) on all vector/matrix classes - causes compilation failure (non-matching function declarations and definitions due to vector/matrix parameters). Also tried to add it to all forward-declarations and typedefs, but it causes only a few more warnings about ignored attribute. --- src/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f1eadbb6..cd3403c21 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,5 +1,11 @@ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Wold-style-cast -Winit-self -pedantic -std=c++0x -fvisibility=hidden") +# Disable strict aliasing for GCC 4.4, as it breaks RectangularMatrix::from() +# (and I have no better solution for that yet) +if(CORRADE_GCC44_COMPATIBILITY) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-strict-aliasing") +endif() + # -Wdouble-promotion is supported from GCC 4.6 # TODO: do this with check_c_compiler_flags() if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_CXX_COMPILER_VERSION}" VERSION_LESS "4.6.0")