https://gcc.gnu.org/bugzilla/show_bug.cgi?id=61597
--- Comment #12 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to Jonathan Wakely from comment #11) > decltype(iter += i) is Iter& so you return a reference to a temporary which > goes out of scope Sorry, temporary is the wrong word - a reference to a local variable, which goes out of scope. It's undefined behaviour.