Thread overview | |||||
---|---|---|---|---|---|
|
May 03, 2011 [Issue 5922] New: immutable and static variables usage in asm{} | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=5922 Summary: immutable and static variables usage in asm{} Product: D Version: D2 Platform: x86 OS/Version: Windows Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-05-03 03:04:41 PDT --- I am not sure about the errors shown here (so no keywords). Please close this bug report if things here are working as expected. D2 code: void main() { immutable size_t x = 10; asm { mov EDI, x; } } DMD 2.052 shows the error: test.d(2): Error: Integer constant expression expected instead of x = 10u -------------------------- D2 code, static (thread-local) variables can't be used in ASM: void main() { static size_t x = 10; asm { mov EDI, x; } } It produces: object.Error: Access Violation They work using __gshared, this gives no errors: void main() { __gshared static size_t x = 10; asm { mov EDI, x; } } My suggestion is to remove this source of errors. One solution may be to disallow the direct access to static variables from asm code, avoiding this bug. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
March 02, 2012 [Issue 5922] immutable and static variables usage in asm{} | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5922 Denis <verylonglogin.reg@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |verylonglogin.reg@gmail.com --- Comment #1 from Denis <verylonglogin.reg@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: ------- |
January 16, 2013 [Issue 5922] immutable and static variables usage in asm{} | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=5922 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies@gmail.com --- Comment #2 from yebblies <yebblies@gmail.com> 2013-01-17 00:04:57 EST --- For some reason x's initializer is "x = 10" instead of just "10". Probably a side effect of some hack. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation