[Issue 11394] New: NRVO should work for object field initialization in constructor
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Oct 30 19:18:11 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11394
Summary: NRVO should work for object field initialization in
constructor
Product: D
Version: D2
Platform: All
OS/Version: All
Status: NEW
Keywords: wrong-code
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: k.hara.pg at gmail.com
--- Comment #0 from Kenji Hara <k.hara.pg at gmail.com> 2013-10-30 19:18:09 PDT ---
Spin-off issue from http://d.puremagic.com/issues/show_bug.cgi?id=11343#c15
At the line 18, NRVO should work, then p1, p2, p3 should print same address.
extern(C) int printf(const char*, ...);
static int[3] make(in int x, out const(int)* p) pure
{
typeof(return) a;
a[0] = x;
a[1] = x + 1;
a[2] = x + 2;
p = a.ptr;
return a;
}
struct Bar
{
immutable int[3] arr;
this(int x, out const(int)* p2)
{
const(int)* p1;
this.arr = make(x, p1); // Line 18: NRVO should work
p2 = this.arr.ptr;
printf("p1 = %p\np2 = %p\n", p1, p2);
//assert(p1 == p2);
}
}
void main()
{
const(int)* p2;
auto b = Bar(5, p2);
const(int)* p3 = b.arr.ptr;
printf("p3 = %p\n", p3);
//assert(p2 == p3);
}
--
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