On Thursday, 14 April 2022 at 12:10:04 UTC, ag0aep6g wrote:
On 14.04.22 13:42, wjoe wrote:
Undefined behavior yes, but regardless the example proves it
can be done in @system code.
A few versions ago, possibly due to a bug or regression, the
compiler didn't complain in @safe code either.
Of course you are correct academically. However, since it's
possible, I'd wager my last hat that code like this is out in
the wild.
No, it cannot be done in @system code. The example only proves
that you can write nonsense code that has no defined meaning.
Note that the nonsense you wrote behaves as you describe only
in Windows. Elsewhere, you get a segfault.
But it doesn't matter how the executable actually behaves. You
cannot cite the result of undefined behavior when arguing
language semantics.
Well I'm not using Windows so I wouldn't know but I compiled an
ran that program on Linux and it didn't segfault. If it had I
wouldn't have included that part in my reply.
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 ?