Mercurial > projects > dstress
changeset 1365:3da73e4504c4
[Issue 997] [Regression] Struct-returning function that conditionally passes the result of another function straight through doesn't work (NRVO bug?)
Stewart Gordon <smjg@iname.com>
2007-02-22
http://d.puremagic.com/issues/show_bug.cgi?id=997
author | thomask |
---|---|
date | Mon, 26 Feb 2007 11:31:35 +0000 |
parents | 8862d9e3bd3c |
children | cb2353467b1c |
files | run/s/struct_28_A.d run/s/struct_28_B.d run/s/struct_28_C.d run/s/struct_28_D.d run/s/struct_28_E.d |
diffstat | 5 files changed, 170 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- /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 <smjg@iname.com> +// @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; +}
--- /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 <smjg@iname.com> +// @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; +}
--- /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 <smjg@iname.com> +// @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; +}
--- /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 <smjg@iname.com> +// @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; +}
--- /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 <smjg@iname.com> +// @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; +}