Discussion Thread: DIP 1035-- at system Variables--Final Review

Paul Backus snarwin at gmail.com
Fri Mar 4 14:16:32 UTC 2022


On Friday, 4 March 2022 at 14:00:31 UTC, Dennis wrote:
> On Friday, 4 March 2022 at 13:09:42 UTC, Paul Backus wrote:
>> As a result, the compiler will not allow you to 
>> void-initialize a `void[1]` in `@safe` code:
>>
>> ```d
>> void main() @safe {
>>     void[1] a = void; // error
>> }
>> ```
>
> That's new to me, and the error makes no sense considering you 
> can (implicitly) convert any array to a `void[]` even in 
> `@safe` code, so you can still do this:
>
> ```D
> void main() @safe {
>     ubyte[1] x = void;
>     void[1] y = x;
> }
> ```

Yes, I think this is a case of the compiler (and the spec) 
applying rules more broadly than is strictly necessary, since 
`void`-initializing a `void[1]` cannot *actually* lead to UB in 
`@safe` code on its own.


More information about the Digitalmars-d mailing list