From 1345a0768d076ffe568959cf931e7316feabd91e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Wed, 2 Mar 2022 16:05:24 +0100 Subject: [PATCH 1/7] Compile warnings in Attribute.hpp G++ 11 does not understand that these variables are not primitive types and complains about possibly uninitialized values. Use the {} constructor to fix this. --- include/openPMD/backend/Attribute.hpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/include/openPMD/backend/Attribute.hpp b/include/openPMD/backend/Attribute.hpp index 87ffc8a0c0..298f4f940c 100644 --- a/include/openPMD/backend/Attribute.hpp +++ b/include/openPMD/backend/Attribute.hpp @@ -132,7 +132,7 @@ auto doConvert(T *pv) -> U typename T::value_type, typename U::value_type>) { - U res; + U res{}; res.reserve(pv->size()); std::copy(pv->begin(), pv->end(), std::back_inserter(res)); return res; @@ -149,7 +149,7 @@ auto doConvert(T *pv) -> U typename T::value_type, typename U::value_type>) { - U res; + U res{}; res.reserve(pv->size()); std::copy(pv->begin(), pv->end(), std::back_inserter(res)); return res; @@ -167,7 +167,7 @@ auto doConvert(T *pv) -> U typename T::value_type, typename U::value_type>) { - U res; + U res{}; if (res.size() != pv->size()) { throw std::runtime_error( @@ -189,7 +189,7 @@ auto doConvert(T *pv) -> U { if constexpr (std::is_convertible_v) { - U res; + U res{}; res.reserve(1); res.push_back(static_cast(*pv)); return res; From f2ea3e1e7245e26552a04767463b903f62f0676b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 8 Mar 2022 13:05:24 +0100 Subject: [PATCH 2/7] Ignore deprecated AccessType in SerialIOTest --- test/SerialIOTest.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 6209f47d8c..22568a1476 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -414,6 +414,11 @@ TEST_CASE("available_chunks_test_json", "[serial][json]") TEST_CASE("multiple_series_handles_test", "[serial]") { + /* + * clang also understands these pragmas. + */ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wdeprecated-declarations" /* * First test: No premature flushes through destructor when another copy * is still around @@ -456,6 +461,7 @@ TEST_CASE("multiple_series_handles_test", "[serial]") */ series_ptr->flush(); } +#pragma GCC diagnostic pop } void close_iteration_test(std::string file_ending) From 8d736b4ca21eb6ec9d71c6f58b216ba12626c1c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 8 Mar 2022 13:18:11 +0100 Subject: [PATCH 3/7] ICC issue: statement unreachable --- include/openPMD/backend/Attribute.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/openPMD/backend/Attribute.hpp b/include/openPMD/backend/Attribute.hpp index 298f4f940c..6aa6c39222 100644 --- a/include/openPMD/backend/Attribute.hpp +++ b/include/openPMD/backend/Attribute.hpp @@ -122,6 +122,7 @@ class Attribute template auto doConvert(T *pv) -> U { + (void)pv; if constexpr (std::is_convertible_v) { return static_cast(*pv); @@ -199,7 +200,6 @@ auto doConvert(T *pv) -> U "getCast: no scalar to vector conversion possible."); } - (void)pv; throw std::runtime_error("getCast: no cast possible."); } From 2d29dd374044084458fea0acd3e78eaecd2d5608 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Tue, 15 Mar 2022 18:26:28 +0100 Subject: [PATCH 4/7] Put throw statement into an else branch ICC seems to resolve reachability of statements after resolving constexpr if --- include/openPMD/backend/Attribute.hpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/include/openPMD/backend/Attribute.hpp b/include/openPMD/backend/Attribute.hpp index 6aa6c39222..5b7a77bec4 100644 --- a/include/openPMD/backend/Attribute.hpp +++ b/include/openPMD/backend/Attribute.hpp @@ -199,8 +199,10 @@ auto doConvert(T *pv) -> U throw std::runtime_error( "getCast: no scalar to vector conversion possible."); } - - throw std::runtime_error("getCast: no cast possible."); + else + { + throw std::runtime_error("getCast: no cast possible."); + } } /** Retrieve a stored specific Attribute and cast if convertible. From 697d657fa1bfb556e217092d7f3e39d75c5c3674 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Thu, 17 Mar 2022 16:58:36 +0100 Subject: [PATCH 5/7] Add pragma for ICPC --- include/openPMD/backend/Attribute.hpp | 40 +++++++++++++++++++-------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/include/openPMD/backend/Attribute.hpp b/include/openPMD/backend/Attribute.hpp index 5b7a77bec4..644991c907 100644 --- a/include/openPMD/backend/Attribute.hpp +++ b/include/openPMD/backend/Attribute.hpp @@ -138,8 +138,10 @@ auto doConvert(T *pv) -> U std::copy(pv->begin(), pv->end(), std::back_inserter(res)); return res; } - - throw std::runtime_error("getCast: no vector cast possible."); + else + { + throw std::runtime_error("getCast: no vector cast possible."); + } } // conversion cast: array to vector // if a backend reports a std::array<> for something where @@ -155,9 +157,11 @@ auto doConvert(T *pv) -> U std::copy(pv->begin(), pv->end(), std::back_inserter(res)); return res; } - - throw std::runtime_error( - "getCast: no array to vector conversion possible."); + else + { + throw std::runtime_error( + "getCast: no array to vector conversion possible."); + } } // conversion cast: vector to array // if a backend reports a std::vector<> for something where @@ -181,9 +185,11 @@ auto doConvert(T *pv) -> U } return res; } - - throw std::runtime_error( - "getCast: no vector to array conversion possible."); + else + { + throw std::runtime_error( + "getCast: no vector to array conversion possible."); + } } // conversion cast: turn a single value into a 1-element vector else if constexpr (auxiliary::IsVector_v) @@ -195,14 +201,26 @@ auto doConvert(T *pv) -> U res.push_back(static_cast(*pv)); return res; } - - throw std::runtime_error( - "getCast: no scalar to vector conversion possible."); + else + { + throw std::runtime_error( + "getCast: no scalar to vector conversion possible."); + } } else { throw std::runtime_error("getCast: no cast possible."); } +#if defined(__INTEL_COMPILER) +/* + * ICPC has trouble with if constexpr, thinking that return statements are + * missing afterwards. Deactivate the warning. + * Note that putting a statement here will not help to fix this since it will + * then complain about unreachable code. + * https://community.intel.com/t5/Intel-C-Compiler/quot-if-constexpr-quot-and-quot-missing-return-statement-quot-in/td-p/1154551 + */ +#pragma warning(disable : 1011) +#endif } /** Retrieve a stored specific Attribute and cast if convertible. From 6aba02139ede19d146274ba6a8982e97241769d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Mon, 21 Mar 2022 11:13:02 +0100 Subject: [PATCH 6/7] Push pragma only in G++ and Clang --- test/SerialIOTest.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index 22568a1476..f0dcf55b37 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -414,11 +414,16 @@ TEST_CASE("available_chunks_test_json", "[serial][json]") TEST_CASE("multiple_series_handles_test", "[serial]") { +#if defined(__INTEL_COMPILER) +#pragma warning(disable : 2282) +#endif /* * clang also understands these pragmas. */ +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" +#endif /* * First test: No premature flushes through destructor when another copy * is still around @@ -461,7 +466,12 @@ TEST_CASE("multiple_series_handles_test", "[serial]") */ series_ptr->flush(); } +#if defined(__INTEL_COMPILER) +#pragma warning(disable : 2282) +#endif +#if defined(__GNUC__) || defined(__clang__) #pragma GCC diagnostic pop +#endif } void close_iteration_test(std::string file_ending) From 08041655be7f05ce9249764935bcae264ab23b73 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Franz=20P=C3=B6schel?= Date: Wed, 23 Mar 2022 18:51:30 +0100 Subject: [PATCH 7/7] Two fixes 1. Reset to default warning behavior after disabling 2. Use __GNUC_MINOR__ instead of __GNUC__ --- include/openPMD/backend/Attribute.hpp | 5 ++++- test/SerialIOTest.cpp | 7 ++----- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/include/openPMD/backend/Attribute.hpp b/include/openPMD/backend/Attribute.hpp index 644991c907..f83b99a2ae 100644 --- a/include/openPMD/backend/Attribute.hpp +++ b/include/openPMD/backend/Attribute.hpp @@ -220,8 +220,11 @@ auto doConvert(T *pv) -> U * https://community.intel.com/t5/Intel-C-Compiler/quot-if-constexpr-quot-and-quot-missing-return-statement-quot-in/td-p/1154551 */ #pragma warning(disable : 1011) -#endif } +#pragma warning(default : 1011) +#else +} +#endif /** Retrieve a stored specific Attribute and cast if convertible. * diff --git a/test/SerialIOTest.cpp b/test/SerialIOTest.cpp index f0dcf55b37..d6b30c8ee1 100644 --- a/test/SerialIOTest.cpp +++ b/test/SerialIOTest.cpp @@ -414,13 +414,10 @@ TEST_CASE("available_chunks_test_json", "[serial][json]") TEST_CASE("multiple_series_handles_test", "[serial]") { -#if defined(__INTEL_COMPILER) -#pragma warning(disable : 2282) -#endif /* * clang also understands these pragmas. */ -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__MINOR__) || defined(__clang__) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wdeprecated-declarations" #endif @@ -469,7 +466,7 @@ TEST_CASE("multiple_series_handles_test", "[serial]") #if defined(__INTEL_COMPILER) #pragma warning(disable : 2282) #endif -#if defined(__GNUC__) || defined(__clang__) +#if defined(__GNUC__MINOR__) || defined(__clang__) #pragma GCC diagnostic pop #endif }