all OS functions should be "nothrow @trusted @nogc"
Timon Gehr via Digitalmars-d
digitalmars-d at puremagic.com
Wed Jul 26 17:09:21 PDT 2017
On 27.07.2017 01:56, Andrei Alexandrescu wrote:
> On 07/26/2017 06:16 PM, Steven Schveighoffer wrote:
>> So I guess I should restate that we can assume no implementations
>> exist that intentionally cause UB when stream is NULL (as in Timon's
>> example).
My argument was not that we need to fear implementations that take
explicit measures to screw you, but UB is UB. Compilers can in principle
turn segfaults into any other behaviour they want, and this behaviour
can change between releases. I'd just rather not codify guarantees that
do not exist into the type system, as it is not really feasible to check
them, even if in practice you will in the overwhelming majority get the
expected behaviour.
> Either they check for null, and handle gracefully, or don't
>> check and segfault.
>
> No need to worry about that at all. If worse comes to worst - i.e. we do
> port to such an implementation
How do you notice?
> - we can always provide a thin wrapper
> that checks for NULL then calls the native function. No need to change
> the signatures. -- Andrei
I don't see how that works, as you'd end up with two different
implementations of the same C function. (I.e. you get a name clash in
the object file.)
More information about the Digitalmars-d
mailing list