digitalmars.D.bugs - [Issue 807] New: inout params don't mesh with fpu
- d-bugmail puremagic.com (32/32) Jan 06 2007 http://d.puremagic.com/issues/show_bug.cgi?id=807
- d-bugmail puremagic.com (21/21) Feb 02 2007 http://d.puremagic.com/issues/show_bug.cgi?id=807
http://d.puremagic.com/issues/show_bug.cgi?id=807 Summary: inout params don't mesh with fpu Product: D Version: unspecified Platform: PC OS/Version: All Status: NEW Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla digitalmars.com ReportedBy: default_357-line yahoo.de http://paste.dprogramming.com/dpdd066k.php When putting inout real parameters directly on the floating point stack, doing stuff and popping them back, for some reason the parameter doesn't get changed. Verified on win32/mingw-gdc0.21svn and linux/dmd1.0 Update (5 minutes later) This is beyond odd. I've got an inout variable changing addresses. Replace the test function in the paste with void test(inout real r) { version(Tango) (new DisplayWriter(Cout))("Before: r is "c)(cast(int)cast(void*)&r)("\n"c)(); else writefln("Before: r is ")(cast(void*)(&r)); asm { fld r; fsin; fstp r; } version(Tango) (new DisplayWriter(Cout))("After: r is "c)(cast(int)cast(void*)&r)("\n"c)(); else writefln("After: r is ")(cast(void*)(&r)); } I got the following output: "Before: r is <someaddress>" "After: r is 0" Please enlighten me. Greetings --
Jan 06 2007
http://d.puremagic.com/issues/show_bug.cgi?id=807 bugzilla digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |INVALID ------- Comment #1 from bugzilla digitalmars.com 2007-02-02 03:16 ------- inout parameters are passed by reference, i.e. they are actually a pointer. The sample code is using inline assembler, referencing the inout parameter. So, the inline assembler: void foo(inout real r) { asm { fld r; is actually loading a *pointer* and treating it as if it were a real. Inline assembler does exactly what you tell it to do. To make the above work, use instead: mov EAX,r ; fld real ptr [EAX] ; Not a compiler bug. --
Feb 02 2007