Bug 23130 – Inline asm lets you mov to half a variable.

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2022-05-21T00:25:24Z
Last change time
2024-12-13T19:23:01Z
Keywords
pull
Assigned to
No Owner
Creator
mhh
Moved to GitHub: dmd#18107 →

Comments

Comment #0 by maxhaton — 2022-05-21T00:25:24Z
void foo() { long i = void; static assert(long.sizeof == 8); asm { mov EAX, i; mov i, EAX; } } In 64 bit mode this is correctly rejected, but in 32 bit mode long suddenly is 32 bit as far as the inline assembler is concerned.
Comment #1 by dlang-bot — 2022-05-21T00:42:06Z
@maxhaton created dlang/dmd pull request #14152 "Fix Issues 23130, 19528 : Inline asm was too liberal about operand si…" fixing this issue: - Fix Issues 23130, 19528 : Inline asm was too liberal about operand sizes. A 8-byte type was only considered 8 bytes in 64 bit code, for some reason. This led to inconsistent compilation of extended asm. I tried to add an error message suggesting the use of an instruction like movsx but this code is spaghetti. https://github.com/dlang/dmd/pull/14152
Comment #2 by robert.schadek — 2024-12-13T19:23:01Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18107 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB