Discussion Thread: DIP 1035-- at system Variables--Final Review
    Paul Backus 
    snarwin at gmail.com
       
    Fri Mar  4 13:09:42 UTC 2022
    
    
  
This is my reply to [this post][1] from the feedback thread:
[1]: 
https://forum.dlang.org/post/qbbatlviwhjsnytbypfw@forum.dlang.org
On Friday, 4 March 2022 at 09:39:53 UTC, Dennis wrote:
> On Friday, 25 February 2022 at 21:46:25 UTC, Dukc wrote:
>> Wouldn't putting the handle in union with `void[1]` work?
>
> No, `void[1]` is not a type with unsafe values.
`void[1]` is considered by the compiler to potentially contain 
pointer data, in accordance with this section of the language 
spec:
https://dlang.org/spec/arrays.html#void_arrays
Note in particular the paragraph that begins, "Void arrays can 
also be static".
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
}
```
So, the workaround suggested by Dukc would indeed work.
(By the way, I know this because the first thing I did after I 
read his post in the feedback thread was to actually write out a 
complete example using the `void[1]` workaround and check to see 
if it worked.)
    
    
More information about the Digitalmars-d
mailing list