On Thursday, 19 May 2022 at 18:39:51 UTC, Walter Bright wrote:
>On 5/19/2022 12:30 AM, Dukc wrote:
>One hole that remains: https://forum.dlang.org/thread/kazglmjwsihfewhscioe@forum.dlang.org
According to a reply, the current langauge implementation does not cause anything special to happen, but it is still undefined behaviour in @safe
code if we go by the spec.
I'm aware of that, but if the user selects "ignore the asserts" then he assumes the risk of what happens if the assert would have otherwise tripped.
Agreed. But asserts are often used without regard for performance, because it's assumed they are removed from release code. Which puts pressure to disable them from a release build
>Just like if the user turns off array bounds checking.
We can do a bit better. If an assert trips, the program will go to unknown state, and there's no telling what it will do. But that's still not quite the same as undefined behaviour. If the program trips an assert in @safe
code, it probably won't cause a buffer overflow vulnerability, because @safe
would almost certainly have detected a vulnerability if one existed. But if the spec says "undefined behaviour", the compiler is allowed to optimise so that it creates such a vulnerability - see the linked thread for an example. I know the current compilers do not do that, but the spec allows doing so in the future.