Closed
Description
In Late output operands
part, the code snippet showed
If inlateout was used, then a and c could be allocated to the same register, in which case the first instruction to overwrite the value of c and cause the assembly code to produce the wrong result.
But when I implement the code
#![allow(unused)]
fn main() {
use std::arch::asm;
let mut a: u64 = 4;
let b: u64 = 4;
let c: u64 = 4;
unsafe {
asm!(
"add {0}, {1}",
"add {0}, {2}",
inlateout(reg) a, // change inout into inlateout here
in(reg) b,
in(reg) c,
);
}
assert_eq!(a, 12);
}
, which changes inout
into inlateout
, the assembly code still produces correct result, and nothing wrong happens, that's weird and can't match what it declared.
So I think maybe asm!
macro has been updated and stable, inlateout
keyword has been entended or just that example is uncertain to describe such bad case.
Metadata
Metadata
Assignees
Labels
No labels