Discussion Thread: DIP 1035-- at system Variables--Community Review Round 2
Steven Schveighoffer
schveiguy at gmail.com
Sat Feb 27 20:54:34 UTC 2021
On 2/27/21 3:12 PM, Paul Backus wrote:
> On Saturday, 27 February 2021 at 20:07:30 UTC, Paul Backus wrote:
>>
>> Ah, right, because you're only accessing the int, not the pointer.
>> Good catch.
It's telling that you intuitively thought the system should prevent you
from doing this (as you should!)
>
> ...which means the whole approach doesn't actually work to begin with. D
> is perfectly within its rights to let you void-initialize the union
> (even though it currently doesn't), because @safe code can't access the
> pointer anyway, so it can never lead to undefined behavior.
D is perfectly within its rights to do whatever it wants for @safe code.
It could let you write an array length without extending the array, and
then only allow you accessing the single element pointed at. It could
prevent dereferencing pointers, and still be considered memory-safe. But
there is still the question of whether this is useful to programmers or not.
-Steve
More information about the Digitalmars-d
mailing list