You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The asm! macro incorrectly zeroes high byte register if both high and low byte registers are used for input, and the low byte input value is zero. #97646
AR: As you can see, eax is xored after ah was set to input 0x3d value.
ER: Either the compiler should prevent such high and low byte register usage and refuse to compile such code, either it should not clear ah when it is trying to clear al.
changed the title [-]The asm! macro incorrectly zeroes high byte register if both high and low byte registers are used for input, and low byte input value is zero.[/-][+]The asm! macro incorrectly zeroes high byte register if both high and low byte registers are used for input, and the low byte input value is zero.[/+]on Jun 2, 2022
which is broken in both clang and gcc, though in different ways. In clang which write wins depends on the ordering of the constraints like in rust (unsurprising), in gcc it depends on the order of the writes to the register variables, since those are somewhat an actual thing (despite the docs saying no guarantees are made for anything other than their use with inline asm).
Activity
[-]The asm! macro incorrectly zeroes high byte register if both high and low byte registers are used for input, and low byte input value is zero.[/-][+]The asm! macro incorrectly zeroes high byte register if both high and low byte registers are used for input, and the low byte input value is zero.[/+]asquared31415 commentedon Jun 2, 2022
Minimal reproduction:
godbolt with target
Requires opt-level 1 or greater to reproduce otherwise the zeroing of
eaxgets done first, which is correct. This is possibly a buggy optimization?In 1.60.0 this code started being accepted by #93868
Reproduces in all stable versions since 1.60.0, up to nightly 2022-06-02
talchas commentedon Jun 2, 2022
This is an LLVM breakage, and the equivalent C syntax is
which is broken in both clang and gcc, though in different ways. In clang which write wins depends on the ordering of the constraints like in rust (unsurprising), in gcc it depends on the order of the writes to the register variables, since those are somewhat an actual thing (despite the docs saying no guarantees are made for anything other than their use with inline asm).