You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So the above program could just print "Hi 10". That's pretty weird. Also we're violating the [[noreturn]] on throw_format_error since in this case it actually returns.
Maybe we should introduce a FMT_ALWAYS_ASSERT that always does the (condition) ? (void)0 : assert_fail(~) bit, and have FMT_THROW fallback to FMT_ALWAYS_ASSERT instead of FMT_ASSERT?
The text was updated successfully, but these errors were encountered:
Maybe we should introduce a FMT_ALWAYS_ASSERT that always does the (condition) ? (void)0 : assert_fail(~) bit, and have FMT_THROW fallback to FMT_ALWAYS_ASSERT instead of FMT_ASSERT?
makes sense. and actually
# define FMT_THROW(x) \
do { \
fmt::detail::assert_fail(__FILE__, __LINE__, x.what()); \
} while (false)
# endif
I don't think we need FMT_ALWAYS_ASSERT but replacing assert with direct invocation of fmt::detail::assert_fail in that particular case makes sense. A PR is welcome.
error_handler::on_error
does this:fmt/include/fmt/core.h
Lines 635 to 638 in d8973bf
Which hides the throwing behavior behind a macro:
fmt/include/fmt/format-inl.h
Lines 39 to 41 in d8973bf
Which conditionally either throws or asserts:
fmt/include/fmt/format.h
Lines 105 to 128 in d8973bf
But asserting... might not assert:
fmt/include/fmt/core.h
Lines 330 to 341 in d8973bf
What this means is that a program like:
could:
NDEBUG
isn't defined, terminate after printing an error about bad format specifier.-fno-exceptions -DNDEBUG
), just... keep... going?So the above program could just print "Hi 10". That's pretty weird. Also we're violating the
[[noreturn]]
onthrow_format_error
since in this case it actually returns.Maybe we should introduce a
FMT_ALWAYS_ASSERT
that always does the(condition) ? (void)0 : assert_fail(~)
bit, and haveFMT_THROW
fallback toFMT_ALWAYS_ASSERT
instead ofFMT_ASSERT
?The text was updated successfully, but these errors were encountered: