lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master e46036b 2/3: Fix tn_range_test compilation wi


From: Greg Chicares
Subject: [lmi-commits] [lmi] master e46036b 2/3: Fix tn_range_test compilation with gcc6, revisited
Date: Fri, 18 Aug 2017 20:45:02 -0400 (EDT)

branch: master
commit e46036bb63911e7e85d63e58ef372200b8f68e2f
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Fix tn_range_test compilation with gcc6, revisited
    
    The changes in the immediately preceding commit were intended only to
    work around an eager compiler diagnostic, so it seemed best to explain
    their purpose and link to the mailing list where they were discussed.
    Rewrote one of the changes so that it excludes type bool explicitly;
    the others resist that sort of rewrite as explained in a comment.
---
 tn_range_test.cpp | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tn_range_test.cpp b/tn_range_test.cpp
index 56f2125..b5b45c4 100644
--- a/tn_range_test.cpp
+++ b/tn_range_test.cpp
@@ -29,6 +29,7 @@
 
 #include <algorithm>                    // min()
 #include <sstream>
+#include <type_traits>                  // is_same, remove_cv
 
 // This should fail to compile:
 //    template class tn_range<double, std::string>;
@@ -137,7 +138,7 @@ void tn_range_test::test_auxiliary_functions(char const* 
file, int line)
     T const minT = std::numeric_limits<T>::lowest();
 
     INVOKE_BOOST_TEST(!is_strictly_between_extrema(maxT), file, line);
-    if(T(1) < maxT)
+    if(!std::is_same<bool,typename std::remove_cv<T>::type>::value)
         {
         INVOKE_BOOST_TEST( is_strictly_between_extrema<T>(1), file, line);
         }
@@ -152,8 +153,12 @@ void tn_range_test::test_auxiliary_functions(char const* 
file, int line)
 
     if(minT < 0)
         {
+        // The left-hand side is cast to T to avoid gcc 'bool-compare'
+        // diagnostics. An 'is_bool' conditional wouldn't prevent the
+        // macros from being expanded. See:
+        //   https://lists.nongnu.org/archive/html/lmi/2017-05/msg00029.html
         INVOKE_BOOST_TEST_EQUAL(T(-1), signum(T(-1)), file, line);
-        INVOKE_BOOST_TEST_EQUAL(T(-1), signum(minT), file, line);
+        INVOKE_BOOST_TEST_EQUAL(T(-1), signum(minT ), file, line);
         INVOKE_BOOST_TEST_EQUAL(true , is_exact_integer(T(-1)), file, line);
         }
 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]