Did you know that inline assembly is safe?
Dany12L
dany12719l at gmail.com
Sat May 6 14:55:08 UTC 2023
Hi,
I found that in D for some reason it is possible to declare the
assembly inline as @safe, this honestly seems crazy to me... The
compiler can't do any checks on the assembly code to ensure it's
@safe and it's certainly up to the developer to check it but D is
@trusted to do this.
void main() @safe {
asm @safe {
mov [RIP], 0;
}
}
This code simply compiles and of course then you get SIGSEGV when
you run it..
I believe inline assembly should only be allowed @system and
@trusted, and under no circumstances should it allowed be @safe
More information about the Digitalmars-d
mailing list