Getting action on your favorite D issues
Paul Backus
snarwin at gmail.com
Sat Jun 6 13:42:13 UTC 2020
On Saturday, 6 June 2020 at 13:31:31 UTC, Meta wrote:
> On Saturday, 6 June 2020 at 03:56:43 UTC, Timon Gehr wrote:
>> On 06.06.20 05:40, Meta wrote:
>>>
>>> The linked defect, and the issue you posted, don't really
>>> make sense to me. They both have UB; reading from an
>>> uninitialized variable (= void), or writing to one member of
>>> a union and reading from the other. Invoke Undefined
>>> Behaviour and you get... Undefined Behaviour.
>>
>> Right. It's in @safe code.
>
> Ah, yes, I missed that. Why the hell is = void allowed in @safe
> again? I vaguely remember Walter arguing that it should be for
> some reason.
Iirc it's only forbidden for pointers, because for other types
garbage value != memory corruption. This is reflected in the
recently updated spec section on "safe values" [1], which states:
> For basic data types, all possible bit patterns are safe.
It seems evident from this discussion that the above statement is
not actually true, at least when it comes to bool.
[1] https://dlang.org/spec/function.html#safe-values
More information about the Digitalmars-d
mailing list