Discussion Thread: DIP 1035-- at system Variables--Community Review Round 1
Stanislav Blinov
stanislav.blinov at gmail.com
Wed Jun 10 14:15:31 UTC 2020
From the feedback thread:
On Wednesday, 10 June 2020 at 13:56:11 UTC, Timon Gehr wrote:
> Memory safety cannot depend on the correctness of a `@safe`
> constructor.
> struct VmInstruction {
> @system Opcode opcode; // this need not be private, just a
> valid enum member
> this(Opcode opcode) @safe {
> this.opcode = opcode; // forgot to check
> }
> }
> ...
> void main() @safe {
> auto code = [VmInstruction(cast(Opcode)20)];
> execute(code);
> }
Good observation. It *almost* feels like there's a case lurking
for disallowing enum casts in @safe code.
More information about the Digitalmars-d
mailing list