http://d.puremagic.com/issues/show_bug.cgi?id=4004

           Summary: DMD 2.042 CTFE regression with functions taking ref
                    parameters
           Product: D
           Version: future
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nob...@puremagic.com
        ReportedBy: sandf...@jhu.edu


--- Comment #0 from Rob Jacques <sandf...@jhu.edu> 2010-03-25 13:04:06 PDT ---
There appears to be a weird regression introduced in DMD 2.042 with the compile
time handling of ref parameters (runtime versions of the function are
unaffected). It appears that when a function taking a ref parameter passes it
as a ref parameter to another function. If the first function modifies the
parameter then modifications made by the second function won't be observed.

Below is a very simple test case:

import std.stdio: writeln;

void foo2(ref size_t offset) {
    offset = 8;
}

void foo(ref size_t offset) {
    auto okay = offset;         // Reading from the ref param is okay
    offset += 0;                // comment this line out and it works
    foo2(offset);
}
size_t bar() {
    size_t offset = 0;
    foo(offset);
    return offset;
}
template foobar() { immutable foobar = bar; }

void main(string[] args) {

writeln(foobar!(),'\t', bar ); // prints 0 8 instead of 8 8

}

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

Reply via email to