Description
error_handler::on_error
does this:
Lines 635 to 638 in d8973bf
Which hides the throwing behavior behind a macro:
Lines 39 to 41 in d8973bf
Which conditionally either throws or asserts:
Lines 105 to 128 in d8973bf
But asserting... might not assert:
Lines 330 to 341 in d8973bf
What this means is that a program like:
#include <fmt/format.h>
int main() {
fmt::println(fmt::runtime("Hi {:d}"), "10");
}
could:
- If exceptions are enabled, throw an exception for bad format specifier.
- Otherwise, if
NDEBUG
isn't defined, terminate after printing an error about bad format specifier. - Otherwise (if
-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]]
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
?