# HG changeset patch # User thomask # Date 1172489495 0 # Node ID 3da73e4504c488d2cbe860a9676ee33a430d4ba1 # Parent 8862d9e3bd3cd03d2e1870108f6f1aba0971bbd2 [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) Stewart Gordon 2007-02-22 http://d.puremagic.com/issues/show_bug.cgi?id=997 diff -r 8862d9e3bd3c -r 3da73e4504c4 run/s/struct_28_A.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/struct_28_A.d Mon Feb 26 11:31:35 2007 +0000 @@ -0,0 +1,34 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Stewart Gordon +// @date@ 2007-02-22 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=997 +// @desc@ [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) + +module dstress.run.s.struct_28_A; + +struct Rect { + int left, top, right, bottom; +} + +Rect foo() { + Rect result; + return result; +} + +Rect bar(){ + return defaultRect(); +} + +Rect defaultRect(){ + return Rect.init; +} + +int main() { + if(foo() != bar()){ + assert(0); + } + return 0; +} diff -r 8862d9e3bd3c -r 3da73e4504c4 run/s/struct_28_B.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/struct_28_B.d Mon Feb 26 11:31:35 2007 +0000 @@ -0,0 +1,34 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Stewart Gordon +// @date@ 2007-02-22 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=997 +// @desc@ [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) + +module dstress.run.s.struct_28_B; + +struct Rect { + int left, top, right, bottom; +} + +Rect foo(bool indirect) { + if(indirect){ + return defaultRect(); + }else{ + Rect result; + return result; + } +} + +Rect defaultRect(){ + return Rect.init; +} + +int main() { + if(foo(false) != foo(true)){ + assert(0); + } + return 0; +} diff -r 8862d9e3bd3c -r 3da73e4504c4 run/s/struct_28_C.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/struct_28_C.d Mon Feb 26 11:31:35 2007 +0000 @@ -0,0 +1,35 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Stewart Gordon +// @date@ 2007-02-22 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=997 +// @desc@ [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) + +module dstress.run.s.struct_28_C; + +struct Rect { + int left, top, right, bottom; +} + +Rect foo(bool indirect) { + if(indirect){ + Rect r = defaultRect(); + return r; + }else{ + Rect result; + return result; + } +} + +Rect defaultRect(){ + return Rect.init; +} + +int main() { + if(foo(false) != foo(true)){ + assert(0); + } + return 0; +} diff -r 8862d9e3bd3c -r 3da73e4504c4 run/s/struct_28_D.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/struct_28_D.d Mon Feb 26 11:31:35 2007 +0000 @@ -0,0 +1,34 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Stewart Gordon +// @date@ 2007-02-22 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=997 +// @desc@ [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) + +module dstress.run.s.struct_28_D; + +struct Rect { + int left, top, right, bottom; +} + +Rect foo(bool indirect) { + if(indirect){ + Rect r = defaultRect(); + return r; + }else{ + return Rect.init; + } +} + +Rect defaultRect(){ + return Rect.init; +} + +int main() { + if(foo(false) != foo(true)){ + assert(0); + } + return 0; +} diff -r 8862d9e3bd3c -r 3da73e4504c4 run/s/struct_28_E.d --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/struct_28_E.d Mon Feb 26 11:31:35 2007 +0000 @@ -0,0 +1,33 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Stewart Gordon +// @date@ 2007-02-22 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=997 +// @desc@ [Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?) + +module dstress.run.s.struct_28_E; + +struct Rect { + int left, top, right, bottom; +} + +Rect foo(bool indirect) { + if(indirect){ + return defaultRect(); + }else{ + return Rect.init; + } +} + +Rect defaultRect(){ + return Rect.init; +} + +int main() { + if(foo(false) != foo(true)){ + assert(0); + } + return 0; +}