[Bug c++/59926] Remove temporary move constructor before move assignment

arnoux123 at gmail dot com gcc-bugzilla@gcc.gnu.org
Thu Jan 23 22:15:00 GMT 2014


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59926

--- Comment #2 from Patrick Arnoux <arnoux123 at gmail dot com> ---
(In reply to Jonathan Wakely from comment #1)
> This looks like PR 57176

Thank you for the reference to PR 57676.
Delving into this a bit further, I found the following:

Derived f(Derived d) { return (d) ; }
Derived g(Derived& d) { Derived e = d ; return (e) ; }
Derived h(Derived d) { Derived e = d ; return (e) ; }


        Derived r ;
        Derived u ;
        u = f(r) ;         // (A) Move Ctor to TmpObj, then Move Assign to u.
        u = g(r) ;         // (B) Move Assign to u (No move ctor)
        u = h(r) ;         // (C) Move Assign to u
        Derived v = h(r) ; // (D) straight up 'rvo'

I would have expected case A to behave like B and C and I would ask
if case D could eliminate rvo and do a Move Ctor instead, would that
simplify the code generation.



More information about the Gcc-bugs mailing list