https://gcc.gnu.org/bugzilla/show_bug.cgi?id=123376
--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ah, but we already do. tree_add_const_value_attribute does
/* For early_dwarf force mangling of all referenced symbols. */
tree initializer = init;
STRIP_NOPS (initializer);
/* rtl_for_decl_init punts on other aggregates, and complex values. */
if (AGGREGATE_TYPE_P (type)
|| (TREE_CODE (initializer) == VIEW_CONVERT_EXPR
&& AGGREGATE_TYPE_P (TREE_TYPE (TREE_OPERAND (initializer, 0))))
|| TREE_CODE (type) == COMPLEX_TYPE)
;
else if (initializer_constant_valid_p (initializer, type))
walk_tree (&initializer, mangle_referenced_decls, NULL, NULL);
but here we have AGGREGATE_TYPE_P. But for CONSTRUCTOR loc_list_from_tree_1
will call cst_pool_loc_descr which mangles this. As this only performs
a lookup, it could as well give up if the assembler name isn't computed
yet. So another fix would be to not compute DECL_RTL if it isn't set
yet upon lookup_constant_def. That does risk hash collisions unless
we make this an error case of course.
Just do the tree walking above always would also be a fix. I'm not sure
the comment is true for any type, at least not when CONSTRUCTOR or
COMPLEX_CST.