https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100468
Bug ID: 100468 Summary: set_up_extended_ref_temp via extend_ref_init_temps_1 drops TREE_ADDRESSABLE Product: gcc Version: 12.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: rguenth at gcc dot gnu.org Target Milestone: --- The g++.dg/cpp0x/constexpr-ice12.C shows that when we resolve the initializer from (int &) &TARGET_EXPR <D.2084, NON_LVALUE_EXPR <0>> to (int &) &_ZGRN1A1iE_ we fail to mark _ZGRN1A1iE_ TREE_ADDRESSABLE even though both the TARGET_EXPR and its var were. The following resolves this, but I'm not sure if it is the correct place to fix this. It looks like 'expr' will always be a TARGET_EXPR since it's only a single caller. diff --git a/gcc/cp/call.c b/gcc/cp/call.c index 57bac05fe70..ea97be22f07 100644 --- a/gcc/cp/call.c +++ b/gcc/cp/call.c @@ -12478,6 +12478,8 @@ set_up_extended_ref_temp (tree decl, tree expr, vec<tree, va_gc> **cleanups, VAR. */ if (TREE_CODE (expr) != TARGET_EXPR) expr = get_target_expr (expr); + else if (TREE_ADDRESSABLE (expr)) + TREE_ADDRESSABLE (var) = 1; if (TREE_CODE (decl) == FIELD_DECL && extra_warnings && !TREE_NO_WARNING (decl)) other affected testcases are g++.dg/cpp2a/paren-init1.C, g++.dg/cpp2a/paren-init29.C, g++.dg/cpp2a/paren-init4.C and g++.dg/ext/visibility/ref-temp1.C