We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Describe the bug We get the following error message (with -Werror) when using REQUIRE_NOTHROW on a void function.
REQUIRE_NOTHROW
.../Catch2/src/catch2/internal/catch_test_macro_impl.hpp:79:13: error: useless cast to type 'void' [-Werror=useless-cast] 79 | static_cast<void>(__VA_ARGS__); \ | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .../Catch2/src/catch2/catch_test_macros.hpp:128:34: note: in expansion of macro 'INTERNAL_CATCH_NO_THROW' 128 | #define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, __VA_ARGS__ ) | ^~~~~~~~~~~~~~~~~~~~~~~ mycode.cpp:47:41: note: in expansion of macro 'REQUIRE_NOTHROW'
Expected behavior No Warning.
Reproduction steps
#include <catch2/catch_test_macros.hpp> void op(); TEST_CASE("") { REQUIRE_NOTHROW(op()); }
Although I was not able to reproduce it on godbolt.
Platform information:
-Wuseless-cast
Additional context We just migrated from Catch 2.13.8 with the single include. Before the Code produced no warning.
I'm also willing to fix this with
if constexpr ( std::is_same_v<decltype( __VA_ARGS__ ), \ void> ) { \ __VA_ARGS__; \ } else { \ static_cast<void>( __VA_ARGS__ ); \ } \
The text was updated successfully, but these errors were encountered:
Okay that doesn't solve the warning. So one would need to suppress it?
Sorry, something went wrong.
Suppress -Wuseless-cast Warning
be78006
Fixes catchorg#2520.
0de60d8
Fixes #2520.
Successfully merging a pull request may close this issue.
Describe the bug
We get the following error message (with -Werror) when using
REQUIRE_NOTHROW
on a void function.Expected behavior
No Warning.
Reproduction steps
Although I was not able to reproduce it on godbolt.
Platform information:
-Wuseless-cast
in our warning listAdditional context
We just migrated from Catch 2.13.8 with the single include. Before the Code produced no warning.
I'm also willing to fix this with
The text was updated successfully, but these errors were encountered: