Mercurial > projects > dstress
changeset 1347:5dcdd1cd6a66
[Issue 829] struct operator overload returns a wrong value (suspect NRVO bug)
Tim Fang <timfang2006@126.com>
2007-01-11
http://d.puremagic.com/issues/show_bug.cgi?id=829
author | thomask |
---|---|
date | Wed, 14 Feb 2007 10:09:49 +0000 |
parents | 9084482d7c1e |
children | b586d4d93855 |
files | reporter.txt run/s/struct_27_B.d run/s/struct_27_C.d |
diffstat | 3 files changed, 70 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/reporter.txt Wed Feb 14 10:09:28 2007 +0000 +++ b/reporter.txt Wed Feb 14 10:09:49 2007 +0000 @@ -140,6 +140,7 @@ tetsuya Thomas Kuehne <thomas-dloop@kuehne.THISISSPAM.cn> Tiago Gasiba <tiago.gasiba@gmail.com> +Tim Fang <timfang2006@126.com> Tim Keating Tintor Marko <tm030127d@galeb.etf.bg.ac.yu> Tomasz Stachowiak(aka Tom S / h3r3tic / heretic) <h3r3tic@remove.mat.uni.torun.pl>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/struct_27_B.d Wed Feb 14 10:09:49 2007 +0000 @@ -0,0 +1,35 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Tim Fang <timfang2006@126.com> +// @date@ 2007-01-11 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=829 +// @desc@ [Issue 829] struct operator overload returns a wrong value (suspect NRVO bug) + +module dstress.run.s.struct_27_B; + +struct Vector3{ + float x; + long dummy; + + Vector3 mul(float s){ + Vector3 ret; + ret.x = x*s; + return ret; + } +} + +int main(){ + Vector3 a; + a.x = 1; + + a = a.mul(2); + + if(2 == a.x){ + return 0; + } + assert(0); +} + +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/run/s/struct_27_C.d Wed Feb 14 10:09:49 2007 +0000 @@ -0,0 +1,34 @@ +// $HeadURL$ +// $Date$ +// $Author$ + +// @author@ Tim Fang <timfang2006@126.com> +// @date@ 2007-01-11 +// @uri@ http://d.puremagic.com/issues/show_bug.cgi?id=829 +// @desc@ [Issue 829] struct operator overload returns a wrong value (suspect NRVO bug) + +module dstress.run.s.struct_27_C; + +struct Vector3{ + float x; + + Vector3 mul(float s){ + Vector3 ret; + ret.x = x*s; + return ret; + } +} + +int main(){ + Vector3 a; + a.x = 1; + + a = a.mul(2); + + if(2 == a.x){ + return 0; + } + assert(0); +} + +