On 17.04.22 15:27, H. S. Teoh wrote:
On Sun, Apr 17, 2022 at 01:06:36PM +0000, wjoe via Digitalmars-d-learn wrote:
[...]
On the matter of undefined behavior. Technically a program is in
undefined behavior land after throwing an error, thus every unittest
that continues after assertThrown is therefore nonsense code, is it
not ?

The spec explicitly makes an exception(!) in this case. See 10.24.11.3:

        https://dlang.org/spec/expression.html#assert_expressions

as well as 27.3:

        https://dlang.org/spec/unittest.html

But the failing assert is not part of the unittest directly. It's in a function that is called from the unittest. It takes a generous interpretation of the spec to include such asserts in the exception.

Letting failing asserts cause UB is a mistake anyway. It stems from a misguided desire to re-use asserts for optimization, when nobody actually uses them that way.

Reply via email to