https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106508
--- Comment #1 from Andrew Pinski <pinskia at gcc dot gnu.org> --- The first case you use default capturing as reference, therefor this will be captured just fine. The second case is similar to: struct f1{int *a;}; struct f1 f(int t) { struct f1 t1 = {&t}; return t1; } Which I thought we warned about but it looks like I was wrong.