Bug 9375 – wrong code when assigning to ref in CTFE
Status
RESOLVED
Resolution
DUPLICATE
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-01-22T18:13:00Z
Last change time
2014-04-21T08:15:47Z
Keywords
CTFE, wrong-code
Assigned to
nobody
Creator
nilsbossung
Comments
Comment #0 by nilsbossung — 2013-01-22T18:13:41Z
Related to issue 7887. While 7887 ICEs, this one compiles, but produces wrong values.
ref r(ref int[][] a) {
return a[0];
}
auto go() {
int[][] a = [[]];
r(a) = [42];
return a;
}
void main() {
enum ct = go();
auto rt = go();
assert(ct == rt); // fails
}
Comment #1 by yebblies — 2013-11-23T04:15:21Z
The return exp is interpreted with ctfeNeedsLvalue, but either I don't understand what that means or there is a bug, because it ends up with '[]' (what you'd expect from a non-ref return)
This gets assigned to, but it doesn't matter. The original [[]] is unchanged. Changing ReturnStatement to ask for ctfeNeedsLvalueRef breaks other code.
Comment #2 by k.hara.pg — 2014-04-21T08:15:47Z
Fixed in git-head, because issue 7887 is properly fixed.
*** This issue has been marked as a duplicate of issue 7887 ***