safety: null checks
snarwin at gmail.com
Mon Nov 23 12:03:49 UTC 2020
On Monday, 23 November 2020 at 12:01:08 UTC, Johan Engelen wrote:
> On Sunday, 22 November 2020 at 23:00:25 UTC, Ola Fosheim
> Grostad wrote:
>> On Sunday, 22 November 2020 at 22:36:40 UTC, Paul Backus wrote:
>>> Memory safety is concerned specifically with avoiding
>>> undefined behavior. Crashing the program isn't undefined
>>> behavior, so it's allowed in @safe code.
>> I understand what you mean, but at high optimization levels
>> dereferencing a null pointer can trigger undefined behaviour.
> I'll reiterate what I've been saying many times already: in
> LDC, null dereference in Undefined Behavior. What follows is
> that code should _actively_ check for null to be safe. Checking
> for null is not included by the compiler in @safe code.
Then LDC allows memory corruption in @safe code, which is a bug.
More information about the Digitalmars-d