Thread overview |
---|
March 17, 2012 [Issue 7720] New: asm silent wrong code generation | ||||
---|---|---|---|---|
| ||||
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 --- Comment #0 from deadalnix <deadalnix@gmail.com> 2012-03-17 12:56:07 PDT --- 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: ------- |
March 18, 2012 [Issue 7720] asm silent wrong code generation | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | http://d.puremagic.com/issues/show_bug.cgi?id=7720 yebblies <yebblies@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |yebblies@gmail.com --- Comment #1 from yebblies <yebblies@gmail.com> 2012-03-18 11:21:41 EST --- 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: ------- |
March 18, 2012 [Issue 7720] asm silent wrong code generation | ||||
---|---|---|---|---|
| ||||
Posted in reply to deadalnix | http://d.puremagic.com/issues/show_bug.cgi?id=7720 --- Comment #2 from deadalnix <deadalnix@gmail.com> 2012-03-18 06:04:39 PDT --- (In reply to comment #1) > 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. 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: ------- |
Copyright © 1999-2021 by the D Language Foundation