Nux

Code review comment for lp:~3v1n0/nux/callgrind-improvements

Revision history for this message
Andrea Azzarone (azzar1) wrote :

> Geometry const& geo = view->GetAbsoluteGeometry();
> parent = view->GetToplevel();
>
> As far as I can see, if this actually works, it works only by accident. This
> binds a C++ reference to the return value of a function. The return value is a
> temporary that will disappear the instant the function completes.
>

Are you sure? The standards says:

«...
C obj1 ;
const C & cr = C (16)+ C (23);
C obj2 ;

the expression C(16)+C(23) creates three temporaries. A first temporary T1 to hold the result of the expression C(16), a second temporary T2 to hold the result of the expression C(23), and a third temporary T3 to hold the result of the addition of these two expressions. The temporary T3 is then bound to the reference cr. It is unspecified whether T1 or T2 is created first. On an implementation where T1 is created before T2, it is guaranteed that T2 is destroyed before T1.
The temporaries T1 and T2 are bound to the reference parameters of operator+; these temporaries are destroyed at the
end of the full expression containing the call to operator+. **** The temporary T3 bound to the reference cr is destroyed at the end of cr’s lifetime, that is, at the end of the program... *** »

> Further down in the function, we have:
>
> m_dirty_areas.push_back(geo);
>
> This looks like it pushes a dangling reference.

« Back to merge proposal