Summary: DMD 2.042 CTFE regression with functions taking ref
           Product: D
           Version: future
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Keywords: wrong-code
          Severity: regression
          Priority: P2
         Component: DMD

--- Comment #0 from Rob Jacques <> 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
size_t bar() {
    size_t offset = 0;
    return offset;
template foobar() { immutable foobar = bar; }

void main(string[] args) {

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


Configure issuemail:
------- You are receiving this mail because: -------

Reply via email to