lmi-commits
[Top][All Lists]
Advanced

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

[lmi-commits] [lmi] master 463b65b 2/3: Fix defect introduced 20170409T1


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 463b65b 2/3: Fix defect introduced 20170409T1141Z: impermissible constexpr
Date: Tue, 27 Mar 2018 19:19:43 -0400 (EDT)

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

    Fix defect introduced 20170409T1141Z: impermissible constexpr
    
    In commit 55d589680, various function templates were made constexpr,
    conditional on "201402L < __cplusplus", which was not true for the
    version of gcc then used in production, but has since become true
    (the conditionals accordingly having been removed). However, the
    floating-to-integral conversion could not actually be constexpr, e.g.
    because it used std::ostringstream; now it does not. See:
      https://lists.nongnu.org/archive/html/lmi/2018-03/msg00085.html
    et seqq.
---
 bourn_cast.hpp | 16 ++--------------
 1 file changed, 2 insertions(+), 14 deletions(-)

diff --git a/bourn_cast.hpp b/bourn_cast.hpp
index 50d1714..407649a 100644
--- a/bourn_cast.hpp
+++ b/bourn_cast.hpp
@@ -24,12 +24,9 @@
 
 #include "config.hpp"
 
-#include "rtti_lmi.hpp"                 // lmi::TypeInfo [demangling]
-
 #include <cmath>                        // isinf(), isnan(), ldexp(), signbit()
 #include <limits>
-#include <sstream>
-#include <stdexcept>
+#include <stdexcept>                    // runtime_error
 #include <type_traits>                  // integral_constant
 
 #if defined __GNUC__
@@ -185,16 +182,7 @@ constexpr inline To bourn_cast(From from, std::true_type, 
std::false_type)
     To const r = static_cast<To>(from);
     if(r != from)
         {
-        lmi::TypeInfo from_type(typeid(From));
-        lmi::TypeInfo   to_type(typeid(To  ));
-        std::ostringstream oss;
-        oss.setf(std::ios_base::fixed, std::ios_base::floatfield);
-        oss
-            << "Cast from " << from << " [" << from_type << "]"
-            << " to "       << r    << " [" << to_type   << "]"
-            << " would not preserve value."
-            ;
-        throw std::runtime_error(oss.str());
+        throw std::runtime_error("Cast would not preserve value.");
         }
     return r;
 }



reply via email to

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