https://issues.dlang.org/show_bug.cgi?id=17226
Paul Backus <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] --- Comment #7 from Paul Backus <[email protected]> --- To be specific, the issue here is that according to the language spec: > The first AssignExpression must evaluate to true. If it does not, an > Assert Failure has occurred and the program enters an Invalid State. > > [...] > > Undefined Behavior: Once in an Invalid State the behavior of the > continuing execution of the program is undefined. i.e., once the condition has been evaluated to false, continuing to execute is undefined *regardless* of what happens in the evaluation of the message. Perhaps the simplest way to fix this is to have assert(condition, message) evaluate the message *first*, so that Ali's example has behavior equivalent to the following code: --- import std.format; void foo(int i) { auto __msg = format("Bad parameter:", i); assert(i == 42, __msg); } void main() { foo(43); } --- This way, if the message expression throws, the assert's condition is never evaluated, and the program does not enter an invalid state. --
