D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 6751 - [CTFE] ref argument of AA doesn't work
Summary: [CTFE] ref argument of AA doesn't work
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: x86 Windows
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-10-01 09:00 UTC by Hisayuki Mima
Modified: 2011-10-04 16:39 UTC (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Hisayuki Mima 2011-10-01 09:00:53 UTC
void f(ref int i, ref string str, ref int[int] aa){
    i = 2;
    str ~= "hello";
    aa[1] = 2;
    assert(aa[1] == 2);
}

static assert({
    int[int] aa;
    int i;
    string str;
    f(i, str, aa);
    assert(i == 2);// OK
    assert(str == "hello");// OK
    assert(aa[1] == 2);// Error: cannot index null array aa
}());

The above code doesn't be compiled by the dmd v2.056 DEBUG built from github after the commit 42fea4c1f2.
This means that ref argument of AA doesn't work well in CTFE.
Comment 1 Don 2011-10-02 13:29:35 UTC
This bug only applies in the case where the AA is null, at the moment when it is passed by reference.