From 6ea41e29f53bdd7b7faeeae9480a9f4962f5ebd2 Mon Sep 17 00:00:00 2001 From: Enrico Seiler Date: Thu, 10 Oct 2024 14:53:13 +0200 Subject: [PATCH] [MISC] Add -Wnrvo warning --- .../detail/algorithm_executor_blocking.hpp | 5 +++-- .../utility/detail/type_name_as_string.hpp | 15 +++++++++------ test/seqan3-test.cmake | 19 ++++++++++++------- 3 files changed, 24 insertions(+), 15 deletions(-) diff --git a/include/seqan3/core/algorithm/detail/algorithm_executor_blocking.hpp b/include/seqan3/core/algorithm/detail/algorithm_executor_blocking.hpp index e399f67fcc..9018f25474 100644 --- a/include/seqan3/core/algorithm/detail/algorithm_executor_blocking.hpp +++ b/include/seqan3/core/algorithm/detail/algorithm_executor_blocking.hpp @@ -197,13 +197,14 @@ class algorithm_executor_blocking } while (status == fill_status::empty_buffer); + std::optional result{std::nullopt}; if (status == fill_status::end_of_resource) - return {std::nullopt}; + return result; assert(status == fill_status::non_empty_buffer); assert(bucket_it != buffer_it->end()); - std::optional result = std::ranges::iter_move(bucket_it); + result = std::ranges::iter_move(bucket_it); go_to_next_result(); // Go to next buffered result. return result; } diff --git a/include/seqan3/utility/detail/type_name_as_string.hpp b/include/seqan3/utility/detail/type_name_as_string.hpp index 5151dd46b7..00484a2a3d 100644 --- a/include/seqan3/utility/detail/type_name_as_string.hpp +++ b/include/seqan3/utility/detail/type_name_as_string.hpp @@ -56,12 +56,15 @@ inline std::string const type_name_as_string = []() // itself, since the type is directly given by the compiler. See https://github.com/seqan/seqan3/pull/2311. // LCOV_EXCL_START if (status != 0) - return std::string{typeid(type).name()} + " (abi::__cxa_demangle error status (" + std::to_string(status) - + "): " - + (status == -1 ? "A memory allocation failure occurred." - : (status == -2 ? "mangled_name is not a valid name under the C++ ABI mangling rules." - : (status == -3 ? "One of the arguments is invalid." : "Unknown Error"))) - + ")"; + { + demangled_name = + std::string{typeid(type).name()} + " (abi::__cxa_demangle error status (" + std::to_string(status) + "): " + + (status == -1 ? "A memory allocation failure occurred." + : (status == -2 ? "mangled_name is not a valid name under the C++ ABI mangling rules." + : (status == -3 ? "One of the arguments is invalid." : "Unknown Error"))) + + ")"; + return demangled_name; + } // LCOV_EXCL_STOP demangled_name = std::string{std::addressof(*demangled_name_ptr)}; diff --git a/test/seqan3-test.cmake b/test/seqan3-test.cmake index 6b9a21a21d..c6be495b32 100644 --- a/test/seqan3-test.cmake +++ b/test/seqan3-test.cmake @@ -61,18 +61,23 @@ if (NOT TARGET seqan3::test) add_library (seqan3_test INTERFACE) target_compile_options (seqan3_test INTERFACE "-pedantic" "-Wall" "-Wextra" "-Werror") - # GCC12 and above: Disable warning about std::hardware_destructive_interference_size not being ABI-stable. if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") + # GCC12 and above: Disable warning about std::hardware_destructive_interference_size not being ABI-stable. if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 12) target_compile_options (seqan3_test INTERFACE "-Wno-interference-size") endif () - endif () - # GCC on arm64 (M1): Disable notes about ABI changes. Example: - # `parameter passing for argument of type 'std::ranges::single_view' when C++17 is enabled changed to match C++14 in GCC 10.1` - # https://github.com/gcc-mirror/gcc/commit/56fe3ca30e1343e4f232ca539726506440e23dd3 - if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64" AND "${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU") - target_compile_options (seqan3_test INTERFACE "-Wno-psabi") + # Warn about failed return value optimization. + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 14) + target_compile_options (seqan3_test INTERFACE "-Wnrvo") + endif () + + # GCC on arm64 (M1): Disable notes about ABI changes. Example: + # `parameter passing for argument of type 'std::ranges::single_view' when C++17 is enabled changed to match C++14 in GCC 10.1` + # https://github.com/gcc-mirror/gcc/commit/56fe3ca30e1343e4f232ca539726506440e23dd3 + if ("${CMAKE_SYSTEM_PROCESSOR}" MATCHES "arm64") + target_compile_options (seqan3_test INTERFACE "-Wno-psabi") + endif () endif () target_link_libraries (seqan3_test INTERFACE "seqan3::seqan3" "pthread")