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:
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:
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.
Permalink
Reply