7266 – [CTFE] Assign to ref param (that's taken from struct member) is noop

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7266 - [CTFE] Assign to ref param (that's taken from struct member) is noop
Summary: [CTFE] Assign to ref param (that's taken from struct member) is noop
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: dmd (show other issues)
Version: D2
Hardware: Other Windows
: P2 normal
Assignee: No Owner
URL:
Keywords: wrong-code
Depends on:
Blocks:
Reported: 2012年01月10日 19:47 UTC by Nick Sabalausky
Modified: 2012年01月14日 17:41 UTC (History)
1 user (show)

See Also:


Attachments
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Nick Sabalausky 2012年01月10日 19:47:50 UTC
-----------------------------------
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".


AltStyle によって変換されたページ (->オリジナル) /