all OS functions should be "nothrow @trusted @nogc"
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 26 03:01:07 PDT 2017
On 26.07.2017 03:09, Steven Schveighoffer wrote:
> On 7/25/17 8:45 PM, Timon Gehr wrote:
>> ...
>> What Moritz is saying is that the following implementation of fclose
>> is correct according to the C standard:
>>
>> int fclose(FILE *stream){
>> if(stream == NULL){
>> return go_wild_and_corrupt_all_the_memory();
>> }else{
>> return actually_close_the_file(stream);
>> }
>> }
>
> I think we can correctly assume no fclose implementations exist that do
> anything but access data pointed at by stream. Which means a segfault on
> every platform we support.
>
> On platforms that may not segfault, you'd be on your own.
>
> In other words, I think we can assume for any C functions that are
> passed pointers that dereference those pointers, passing null is safely
> going to segfault.
I'm not going to assume that.
More information about the Digitalmars-d
mailing list