silence warning C4100 on MSVC 2019 when exceptions are disabled - #2397
Conversation
|
This is strange because Lines 91 to 100 in a3f762c Do you have a godbolt repro? |
|
I believe that in release mode the FMT_ASSERT is declared ((void)0), which means that the compiler removes everything in the FMT_THROW(x) macro. (Given that exceptions are disabled.) |
|
Right. In this case it should be fixed in the |
|
@vitaut, maybe replace Line 364 in a3f762c to: FMT_INLINE void assert_ignore(bool, const char*) {}
# define FMT_ASSERT(condition, message) ::fmt::detail::assert_ignore((condition), (message))? @mattiasljungstrom, please check this solution. |
|
@vitaut makes sense! This works for my case: # define FMT_ASSERT(condition, message) ((void)message) Or this works for MSVC (note constexpr needed), haven't tried other compilers: FMT_INLINE constexpr void assert_ignore(bool, const char*) {}
# define FMT_ASSERT(condition, message) ::fmt::detail::assert_ignore((condition), (message))
|
33cd0bb to
0c756be
Compare
|
I've updated the PR to use the assert_ignore() solution for FMT_ASSERT. |
|
Can we use the newly added Line 340 in 889bbf2 instead of introducing a new function? |
|
Sure! I've changed the code to use the ::fmt::ignore_unused(), but I had to add FMT_CONSTEXPR since the assert is sometimes used in constexpr functions. |
|
Maybe rewrite template <class ...Ts> FMT_CONSTEXPR void ignore_unused(const Ts& ...) {}and remove |
Was about to suggest the same =) |
|
updated code with @phprus suggestions. |
|
Thank you! |
Removes the following warnings under MSVC 2019 (16.10.2), with W4 enabled and when exceptions are disabled. (/W4 -D_HAS_EXCEPTIONS=0)
fmt\include\fmt\format.h(810,44): warning C4100: 'message': unreferenced formal parameter
fmt\include\fmt/format-inl.h(2553,59): warning C4100: 'message': unreferenced formal parameter