https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100850
--- Comment #4 from Iain Sandoe <iains at gcc dot gnu.org> --- (In reply to Vlad from comment #3) > My bad. It's actually a UB. The lambda lifetime is just over by the moment > of resumption of the co-routine. (oddly enough) we were discussing thia in a BSI meeting yesterday, perhaps the compiler can do more to warn you if you are making a "dangerous" use of reference. The standard itself has a warning about it - but most people don't read the standard, of course. Can this be closed then?