Bug 7266 – [CTFE] Assign to ref param (that's taken from struct member) is noop
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2012-01-10T19:47:00Z
Last change time
2012-01-14T17:41:04Z
Keywords
wrong-code
Assigned to
nobody
Creator
bus_dbugzilla
Comments
Comment #0 by bus_dbugzilla — 2012-01-10T19:47:50Z
-----------------------------------
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".