Just a friendly reminder about using arrays in boolean conditions - null index safety

Nick Treleaven nick at geany.org
Mon Nov 25 21:53:33 UTC 2024


On Monday, 25 November 2024 at 17:27:04 UTC, Steven Schveighoffer 
wrote:
> On Saturday, 23 November 2024 at 00:57:01 UTC, kdevel wrote:
>> Issue 20722 - typeid(X).initializer() breaks safety
>> https://issues.dlang.org/show_bug.cgi?id=20722
>
> Indeed, I don't think this should be considered safe. I don't 
> know how much code would break to change it to system.

There's also the field dereference of a null pointer bug. I think 
if the solution for that is implemented, it would also fix the 
above `initializer` one too - see:
https://issues.dlang.org/show_bug.cgi?id=5176#c29

That relies on a guard page starting at null. However, Walter 
said:

> Of course, if you malloc your own stack, you don't have such 
> protection.

So IIUC any @trusted code that does that (without setting up a 
guard page) would not actually be @safe. And any OS that D is 
ported to that doesn't set up a guard page would also not be 
@safe.


More information about the Digitalmars-d mailing list