https://gcc.gnu.org/bugzilla/show_bug.cgi?id=49974
--- Comment #20 from Andrew Pinski <pinskia at gcc dot gnu.org> --- (In reply to Barry Revzin from comment #19) > Another example of this: > > int get(); > > int const& f() { > int const r = get(); > return r; > } > > int const& g() { > int const& r = get(); > return r; > } > > gcc trunk warns on the incorrect use in f, but it does not currently warn on > the incorrect use in g (which is the exact same bug). clang warns on both. GCC trunk does warn on g but only with optimizations turned on.