www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7266] New: [CTFE] Can't alter ref param taken from struct member

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

           Summary: [CTFE] Can't alter ref param taken from struct member
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: cbkbbejeap mailinator.com



19:47:50 PST ---
-----------------------------------
import std.stdio;
struct S { int a; }

int foo()
{
    S s;
    return bar(s.a);  // A
    //bar(s.a); return s.a; // B
}

int bar(ref int b)
{
    b = 5;
    return b;
}

enum y = foo();

void main()
{
    writeln(y);
}
-----------------------------------

Expected output: 5
Actual output: 0

Same thing occurs with either the "// A" line or the "// B" line uncommented. 
Also occurs with "out" instead of "ref".

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 10 2012
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=7266


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED



17:41:04 PST ---
https://github.com/D-Programming-Language/dmd/commit/1cbd1959e41d39c812a8f4c1a17eb8535d44547a

https://github.com/D-Programming-Language/dmd/commit/1394b3c55c740106555cd484697019e4a9b77109

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jan 14 2012