www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1294] New: referencing fields in static arrays of structs passed as arguments generates invalid code

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1294

           Summary: referencing fields in static arrays of structs passed as
                    arguments generates invalid code
           Product: D
           Version: 1.001
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: major
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: thecybershadow gmail.com


import std.stdio;

struct TestStruct
{
        int dummy0;
        int dummy1;
        int dummy2;
}

void func(TestStruct[2] testarg)
{
        writefln(&testarg);             // outputs m's address, correct
        writefln(&testarg[0]);          // outputs m's address (same as above),
correct
        writefln(&testarg[0].dummy0);   // outputs m's address (same as above),
correct
        writefln(&testarg[0].dummy1);   // outputs the contents of the stack,
one DWORD higher than the "testarg" argument (which holds the address to m) -
the saved stack pointer?
        writefln(&testarg[0].dummy2);   // outputs the contents of the stack,
two DWORDs higher than the "testarg" argument - the return address
}

TestStruct m[2];

void main()
{
        writefln(&m);                    // for reference
        func(m);
}


This goes back from at least 1.001 and up to 1.017 and 2.000. 
It works on GDC.


-- 
Jun 27 2007
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1294


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 1.018 and DMD 2.002


-- 
Jul 01 2007