Teuchos: Teuchos::as fails to compile with -Werror=double-promotion
Created by: tjfulle
When compiling with -Werror=double-promotion
, the following compile time error occurs:
[with OutputRealType = float; InputRealType = double]’:
312 <path>/include/Teuchos_as.hpp:648:47: required from here
>> 313 <path>/include/Teuchos_as.hpp:485:11: error: implicit conversion from ‘float’ to ‘double’ to match other operand of binary expression [-Werror=double-promotion]
314 x < minVal || x > maxVal,
@trilinos/teuchos
Expectations
Teuchos compiles with -Werror=double-promotion
Possible Solution
diff --git a/packages/teuchos/core/src/Teuchos_as.hpp b/packages/teuchos/core/src/Teuchos_as.hpp
index 3a3798809d..f957a6b735 100644
--- a/packages/teuchos/core/src/Teuchos_as.hpp
+++ b/packages/teuchos/core/src/Teuchos_as.hpp
@@ -482,7 +482,7 @@ namespace { // anonymous
// let it pass through, per the rules for propagation of silent
// NaN. (Signaling NaN will signal, but that's OK.)
TEUCHOS_TEST_FOR_EXCEPTION(
- x < minVal || x > maxVal,
+ x < as<InputRealType>(minVal) || x > as<InputRealType>(maxVal),
std::range_error,
"realToReal<" << TypeNameTraits<OutputRealType>::name () << ", "
<< TypeNameTraits<InputRealType>::name () << ">: "