[Issue 5922] immutable and static variables usage in asm{}

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 2 06:37:14 PST 2012


http://d.puremagic.com/issues/show_bug.cgi?id=5922


Denis <verylonglogin.reg at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |verylonglogin.reg at gmail.com


--- Comment #1 from Denis <verylonglogin.reg at gmail.com> 2012-03-02 17:37:11 MSK ---
The first one is definetly a bug with const/immutable local variables:
---
void f() {
    const size_t a = 1; // Error: Integer constant expression expected instead
of a = 1u
    version (D_InlineAsm_X86_64)
        asm { mov RAX, a; }
    else version (D_InlineAsm_X86)
        asm { mov EAX, a; }
    else
        static assert(1);
}
---

The second one looks like expected behaviour because with current inline
assembler for non-stack varable `someVar` instruction `mov EAX, someVar;` is
equal to `mov EAX, [someVar];` and `mov EAX, [n];` where `n` is a displacement
of `someVar` from some initial addres which depends on `someVar` type (global,
shared, or TLS).
Inline assembler behaves in this way but I've never seen any documentation and
reasons *why* does it behave this way because it's really unobvious.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list