[Issue 4004] New: DMD 2.042 CTFE regression with functions taking ref parameters
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Mar 25 13:04:09 PDT 2010
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: nobody at puremagic.com
ReportedBy: sandford at jhu.edu
--- Comment #0 from Rob Jacques <sandford at 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: -------
More information about the Digitalmars-d-bugs
mailing list