digitalmars.D.bugs - [Issue 7720] New: asm silent wrong code generation
- d-bugmail puremagic.com (32/32) Mar 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7720
- d-bugmail puremagic.com (14/14) Mar 17 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7720
- d-bugmail puremagic.com (9/15) Mar 18 2012 http://d.puremagic.com/issues/show_bug.cgi?id=7720
http://d.puremagic.com/issues/show_bug.cgi?id=7720 Summary: asm silent wrong code generation Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: nobody puremagic.com ReportedBy: deadalnix gmail.com See code blow : static uint globalThreadLocal = 123456; uint foo() { asm { naked; mov EAX, globalThreadLocal; ret; } } void main() { uint x = foo(); import std.stdio; writeln(x); } Output garbage. This code should generate an error and not compile as if it was correct. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7720 yebblies <yebblies gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies gmail.com It's not that simple. IIRC "mov EAX, globalThreadLocal" moves the offset of globalThreadLocal into EAX. While this obviously isn't what you expected, this is valid and useful. How else would you get the offset? After all, you're using the inline assembler. The compiler will never be able to protect you against writing incorrect assembly. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 17 2012
http://d.puremagic.com/issues/show_bug.cgi?id=7720It's not that simple. IIRC "mov EAX, globalThreadLocal" moves the offset of globalThreadLocal into EAX. While this obviously isn't what you expected, this is valid and useful. How else would you get the offset? After all, you're using the inline assembler. The compiler will never be able to protect you against writing incorrect assembly.In this case, this behavior should be documented. But this is confusing, because it is not what happen with other variables (variable value is copied into the register). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Mar 18 2012