Asm block instructions corrupted by safe-mode pointer checks
Using a dereferenced pointer as an argument inside an asm block having safe-mode enabled causes a compilation error. It appears that the code for generating runtime safety checks on the pointer deference interferes with the assembly instruction string passed to LLVM.
The compilation error does not happen with safe-mode disabled (--safe=no) and when the deference is done outside the asm block, like ptrDeref does in the example.
Example and actual behavior
fn void main() {
long l = 0xbeef;
long* ptr = &l;
long ptrDeref = *ptr;
asm {
movq $rax, (*ptr);
// movq $rax, ptrDeref; // works
}
}
Compiling outputs the following:
error: <inline asm>:1:2: invalid instruction mnemonic 'std.core.builtin.panicf'
std.core.builtin.panicf
^~~~~~~~~~~~~~~~~~~~~~~
Tested on latest pre-release 0.7.9 (18e28387722e3740b8786d964caaac375a0282bd)
I am afraid this needs to wait until the asm fixes, when all these are addressed.
The workaround will be the only allowed solution anyway.
Oh okay, it's fine.
I'm assuming there will be a subset of expressions not allowed in asm blocks then, is that correct?