Thread overview |
---|
February 22, 2007 [Issue 997] New: [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=997 Summary: [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) Product: D Version: 1.007 Platform: PC OS/Version: Windows Status: NEW Keywords: wrong-code Severity: normal Priority: P2 Component: DMD AssignedTo: bugzilla@digitalmars.com ReportedBy: smjg@iname.com I found this when one of my programs had stopped working. Clearly there is work to be done to get NRVO behaving itself. ---------- import std.stdio, std.string; struct Rect { int left, top, right, bottom; } int main() { print(sizeTest(false)); print(sizeTest(true)); print(defaultRect); return 0; } static Rect sizeTest(bool empty) { if (empty) { Rect result; return result; //return Rect.init; } else { return defaultRect; /+Rect result = defaultRect; return result;+/ } } void print(Rect r) { writefln("(%d, %d)-(%d, %d)", r.left, r.top, r.right, r.bottom); } Rect defaultRect() { return Rect.init; } ---------- (1, 4212215)-(0, 4291676) (0, 0)-(0, 0) (0, 0)-(0, 0) ---------- If I remove the if, or use either of the commented out portions instead, then I get the expected output: ---------- (0, 0)-(0, 0) (0, 0)-(0, 0) (0, 0)-(0, 0) ---------- -- |
February 26, 2007 [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=997 thomas-dloop@kuehne.cn changed: What |Removed |Added ---------------------------------------------------------------------------- OS/Version|Windows |All ------- Comment #1 from thomas-dloop@kuehne.cn 2007-02-26 05:37 ------- Added to DStress as http://dstress.kuehne.cn/run/s/struct_28_A.d http://dstress.kuehne.cn/run/s/struct_28_B.d http://dstress.kuehne.cn/run/s/struct_28_C.d http://dstress.kuehne.cn/run/s/struct_28_D.d http://dstress.kuehne.cn/run/s/struct_28_E.d -- |
April 14, 2007 [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=997 braddr@puremagic.com changed: What |Removed |Added ---------------------------------------------------------------------------- Severity|normal |regression -- |
April 20, 2007 [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=997 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #2 from bugzilla@digitalmars.com 2007-04-20 13:17 ------- Fixed DMD 1.013 -- |
Copyright © 1999-2021 by the D Language Foundation