From bb69a8db5da21f3c6b289d010eaa64e757387dca Mon Sep 17 00:00:00 2001 From: Antonio Sanchez Date: Thu, 12 Nov 2020 13:12:00 -0800 Subject: Explicit casts of S -> std::complex When calling `internal::cast>(x)`, clang often generates an implicit conversion warning due to an implicit cast from type `S` to `T`. This currently affects the following tests: - `basicstuff` - `bfloat16_float` - `cxx11_tensor_casts` The implicit cast leads to widening/narrowing float conversions. Widening warnings only seem to be generated by clang (`-Wdouble-promotion`). To eliminate the warning, we explicitly cast the real-component first from `S` to `T`. We also adjust tests to use `internal::cast` instead of `static_cast` when a complex type may be involved. --- test/basicstuff.cpp | 33 ++------------------------------- 1 file changed, 2 insertions(+), 31 deletions(-) (limited to 'test/basicstuff.cpp') diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index f9044a27a..4ca607c82 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -195,11 +195,8 @@ template void basicStuffComplex(const MatrixType& m) VERIFY(!static_cast(cm).imag().isZero()); } -template::value || internal::is_same::value)> struct casting_test; - - template -struct casting_test { +struct casting_test { static void run() { Matrix m; for (int i=0; i { Matrix n = m.template cast(); for (int i=0; i(m(i, j))); - } - } - } -}; - -template -struct casting_test { - static void run() { - casting_test::run(); - } -}; - -template -struct casting_test, true> { - static void run() { - typedef std::complex TgtScalar; - Matrix m; - for (int i=0; i::value(); - } - } - Matrix n = m.template cast(); - for (int i=0; i(static_cast(m(i, j)))); + VERIFY_IS_APPROX(n(i, j), (internal::cast(m(i, j)))); } } } -- cgit v1.2.3