------- Comment #5 from jakub at gcc dot gnu dot org 2006-06-22 16:58 ------- In GCC trunk bootstrap + regression testing the tree-nrv optimization hits 584 types, out of this 38 cases have TREE_ADDRESSABLE set on the RESULT_DECL (because C++ FE already NRV optimized it, address of <retval> was taken usually when it was constructed, then some optimizations later on set <retval> to a temporary variable and the code that takes &<result> was optimized out), e.g. when compiling fstream-inst.cc in libstdc++-v3. So, bailing out in tree_nrv whenever TREE_ADDRESSABLE (result) would pessimize those. On the other side, in tree_nrv we know that TREE_ADDRESSABLE (found) == 0 (we check for that), so we can either stop copying the addressable flag, or bail if TREE_ADDRESSABLE (result).
-- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28116