Drew DeVault: 1
Require assertion messages to be translation-compatible
1 files changed, 2 insertions(+), 1 deletions(-)
I think that it has too many footguns and it isn't that useful. Out of
nearly 4,000 asserts and aborts in the stdlib there were, what, six of
them which needed to be fixed following this change? And I've heard
To be fair, this feature was only recently-ish added.
*several* people shooting themselves in this particular foot before. I'd
rather make the change to simplify it. IMO it's bad practice to spend
cycles and/or memory generating assertion failure messages anyway, since
in theory, you know, assertions aren't supposed to fail and it's a waste
of time and/or resources.
Yeah I agree. This is part of why we need the builtin to work like
that - it is the only way to conditionally generate the error message
without resorting to if expressions.
The footgun here was that stack-allocated strings don't work with
assert/abort in tests. Are there any others, and would it be too
expensive to fix the test runner to save the message before the stack is
lost?
Is there a reason to not print stack traces when tests abort, regardless
of this patch?
IMO that's a broader problem with defer, not assert. You can replace
the assert with fmt::fatal and it will have the same issue. Your point
still stands though, the problem wouldn't happen with assert after your
patch.
I don't feel very strongly either way wrt this patch, so I'll check out
and let others chime in. It's probably good to note that this is a
breaking change in one of the commit messages.