https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115769
Jakub Jelinek <jakub at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #58908|0 |1 is obsolete| | --- Comment #5 from Jakub Jelinek <jakub at gcc dot gnu.org> --- Created attachment 58912 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=58912&action=edit gcc15-pr115769-wip.patch Updated patch. This works better, but regresses cpp1z/decomp6.C testcase, even if CLEANUP_EXPR (cl) in the patch is replaced with unshare_expr (CLEANUP_EXPR (cl)). For decomp6.C at line 26, i.e. array of 6 As the cleanup is complex duplicating it is a nightmare (tried mostly_copy_tree_r too, but that didn't work either). So, wonder if we instead shouldn't just move also the structure binding base initialization into the try ... finally which destructs it and just use some bool flag set initially to false, after the base initialization set to true and make the cleanup(s) dependent on that flag. Oh, and another problem is I really don't know what to do about namespace scope or block scope static structured bindings, the namespace scope ones at least look similarly to these, but block scope statics seems to use separate guard variables for the ref binding extended var and for the individual structured binding var initializers, so one thread could initialize the former and another thread the latter, in that case it isn't really possible to have temporaries survive across it unless we e.g. move the initialization of all the temporaries to something guarded by the corresponding var.