[Issue 832] NRVO: return inside foreach results in junk
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Jan 27 02:03:19 PST 2007
http://d.puremagic.com/issues/show_bug.cgi?id=832
lio at lunesu.com changed:
What |Removed |Added
----------------------------------------------------------------------------
Severity|normal |major
Keywords| |wrong-code
Summary|Struct copying changed in |NRVO: return inside foreach
|1.0 |results in junk
------- Comment #3 from lio at lunesu.com 2007-01-27 04:03 -------
// Smaller program with same problem.
// Should print "1" three times, but only first is OK
import std.stdio;
struct Struct
{
int langID;
long _force_nrvo;
}
Struct[1] table;
Struct getfirst()
{
foreach(v; table) { //inout also doesn't work
writefln(v.langID);// not OK
return v;
}
}
void main()
{
table[0].langID = 1;
foreach(v; table) {
writefln(v.langID);//OK
break;
}
auto v = getfirst();
writefln(v.langID);// not OK
}
--
More information about the Digitalmars-d-bugs
mailing list