Getting action on your favorite D issues

ag0aep6g anonymous at example.com
Sat Jun 6 14:02:54 UTC 2020


On 06.06.20 15:42, Paul Backus wrote:
> 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

I had thought about special-casing bool there, precisely because of the 
issue at hand. I almost wrote that only 0 and 1 are safe values for bool.

I decided against it, because it seems unlikely that creating values 
beyond 1 will be banned in @safe code. It seems more likely that the 
implementation gets changed to treat all non-zero values as true. At 
least that's what I extrapolate from Walter's position on void 
initialization in general (see 
<https://github.com/dlang/dlang.org/pull/2260/files>).


More information about the Digitalmars-d mailing list