Getting action on your favorite D issues

Joseph Rushton Wakeling joseph.wakeling at webdrake.net
Sat Jun 6 16:54:38 UTC 2020


On Saturday, 6 June 2020 at 16:48:56 UTC, Steven Schveighoffer 
wrote:
> int x = void;
>
> Does not and cannot corrupt memory (assuming everything that 
> uses it is @safe).

Yes, which is presumably why the other example above -- using the 
wrong accessor of a union -- is also allowed in @safe code ... ?

That said, the definition of a safe interface is, according to 
spec, that it exhibits no undefined behaviour:
https://dlang.org/spec/function.html#safe-interfaces

Don't using void-initialized variables or the wrong accessors of 
a union both count as undefined behaviour, even if they are 
memory-safe?


More information about the Digitalmars-d mailing list