https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102359
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |jason at gcc dot gnu.org --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Confirmed. So we end with '&__closure->__this' which indeed isn't an lvalue. The issue here is that we are initializing the VAR_DECL 'this' but that has a DECL_VALUE_EXPR expanding to &__closure->__this: const struct A * const this [value-expr: &__closure->__this]; note the variable is const as well, so emitting a runtime initializer might have other issues (like trapping ...), or in this case, not being an lvalue. But note the FE fails to mark the decl as TREE_READONLY - that would be an easy thing to check (and something we fail to check in is_var_need_auto_init). Thus sth like diff --git a/gcc/gimplify.c b/gcc/gimplify.c index f680292fd91..b2bfab47a2f 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -1824,7 +1824,9 @@ gimple_add_padding_init_for_auto_var (tree decl, bool is_vla, static bool is_var_need_auto_init (tree decl) { - if (auto_var_p (decl) + if (VAR_P (decl) + && !TREE_READONLY (decl) + && auto_var_p (decl) && (flag_auto_var_init > AUTO_INIT_UNINITIALIZED) && (!lookup_attribute ("uninitialized", DECL_ATTRIBUTES (decl))) && !is_empty_type (TREE_TYPE (decl))) should be needed. Jason, any idea?