From fc3f1d78abcff1a4a43741fa8c567009b6b31348 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 11 Mar 2015 03:57:13 +0100 Subject: [PATCH 1/2] [arithmetic] Add workaround for MinGW in determinant. Explicitly create two temporaries and subtract them instead of doing it in one expression. Without it MinGW and probably QCC are generating different results in some cases. In such cases e.g. the sides or cramer's rule values may be inconsistent, also different than values calculated in a program compiled using different compilers. --- include/boost/geometry/arithmetic/determinant.hpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/include/boost/geometry/arithmetic/determinant.hpp b/include/boost/geometry/arithmetic/determinant.hpp index 14edea7182..1c11104961 100644 --- a/include/boost/geometry/arithmetic/determinant.hpp +++ b/include/boost/geometry/arithmetic/determinant.hpp @@ -39,7 +39,13 @@ public : static inline ReturnType apply(U const& ux, U const& uy , V const& vx, V const& vy) { - return rt(ux) * rt(vy) - rt(uy) * rt(vx); + // NOTE: the explicit temporaries are here on purpose + // without them in some cases MinGW and probably QCC + // calculate different results than MSVC and GCC + ReturnType const t1 = rt(ux) * rt(vy); + ReturnType const t2 = rt(uy) * rt(vx); + return t1 - t2; + //return rt(ux) * rt(vy) - rt(uy) * rt(vx); } }; From bc8fedc3f50fda9053ec03785a49bef6cee1e7c3 Mon Sep 17 00:00:00 2001 From: Adam Wulkiewicz Date: Wed, 11 Mar 2015 04:05:06 +0100 Subject: [PATCH 2/2] [test][get_turns] Add cases failing for MinGW before the addition of a workaround in determinant. --- .../overlay/get_turns_linear_linear.cpp | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/test/algorithms/overlay/get_turns_linear_linear.cpp b/test/algorithms/overlay/get_turns_linear_linear.cpp index 9278c02fd6..f7be94e047 100644 --- a/test/algorithms/overlay/get_turns_linear_linear.cpp +++ b/test/algorithms/overlay/get_turns_linear_linear.cpp @@ -290,6 +290,49 @@ void test_all() expected("")("")); } + // 10.03.2015 results different for MinGW and MSVC/GCC + if ( BOOST_GEOMETRY_CONDITION((boost::is_same::value)) ) + { + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(12 10, 13 0.3, 14 0.4, 15 0.5)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3, 12 10)", + expected("miu+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(12 10, 13 0.3, 14 0.4, 15 0.5)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3, 12 10)", + expected("muu==")("ccc==")("mii++")); + + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(13 0.3, 14 0.4, 15 0.5)", + expected("mii++")("ccc==")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3)", + expected("mix+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(13 0.3, 14 0.4, 15 0.5)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(15 0.5, 14 0.4, 13 0.3)", + expected("mux==")("ccc==")("mii++")); + + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(12 10, 13 0.3, 14 0.4)", + expected("mii++")("mux==")); + test_geometry("LINESTRING(0 0, 10 0, 20 1)", + "LINESTRING(14 0.4, 13 0.3, 12 10)", + expected("miu+=")("mui=+")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(12 10, 13 0.3, 14 0.4)", + expected("mui=+")("mix+=")); + test_geometry("LINESTRING(20 1, 10 0, 0 0)", + "LINESTRING(14 0.4, 13 0.3, 12 10)", + expected("muu==")("mii++")); + } + // TODO: //test_geometry("LINESTRING(0 0,2 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102"); //test_geometry("LINESTRING(2 0,0 0,1 0)", "LINESTRING(0 1,0 0,2 0)", "1FF00F102");