all OS functions should be "nothrow @trusted @nogc"

Patrick Schluter via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 27 08:02:58 PDT 2017


On Thursday, 27 July 2017 at 11:46:24 UTC, Steven Schveighoffer 
wrote:
> On 7/27/17 2:48 AM, Jacob Carlborg wrote:
>> And then the compiler runs the "Dead Code Elimination" pass 
>> and we're left with:
>> 
>> void contains_null_check(int* p)
>> {
>>      *p = 4;
>> }
>
> So the result is that it will segfault. I don't see a problem 
> with this. It's what I would have expected.
>
Except that that code was used in the Linux kernel where page 0 
was mapped and thus de-referencing the pointer did not segfault.

The issue that is missed here is for what purpose the compiler is 
used. Will the code always be run in a hosted environment or is 
it used in a freestanding implementation (kernel and embedded 
stuff). The C standard makes a difference between the 2 but the 
compiler gurus apparently do not care.
As for D, Walter's list of constraints for a D compiler makes it 
imho impossible to use the language on smaller embedded platforms 
ring 0 mode x86.
That's why calling D a system language to be somehow 
disingenuous. Calling it an application language to be truer.



More information about the Digitalmars-d mailing list