Reference value of structs not optimized or inlined?
Walter Bright
newshound1 at digitalmars.com
Thu Aug 27 17:17:25 PDT 2009
Jeremie Pelletier wrote:
> Isn't there a way to implement RVO to work on parameters (PVO?) too
> if the storage is const?
No, and it doesn't work for C++ either. Consider:
struct S { int a; }
void foo(const ref S s)
{
assert(s.a == 3);
bar();
assert(s.a == 3); // OOPS!
}
S g;
void bar()
{
g.a = 4;
}
void main()
{
foo(g);
}
More information about the Digitalmars-d
mailing list