------- Comment #6 from jakub at gcc dot gnu dot org 2005-11-11 09:31 ------- Here complete_vars is called (via complete_type->instantiate_class_template->finish_struct_1 call chain) before TYPE_NEEDS_CONSTRUCTING flag is set (mark_used->instantiate_decl->tsubst->build_cplus_array_type call chain), so TREE_READONLY is set on the decl and later on its type becomes TYPE_NEEDS_CONSTRUCTING.
complete_vars calls complete_type before calling cp_apply_type_quals_to_decl, and complete_type should presumably set TYPE_NEEDS_CONSTRUCTING flag (typeck.c:112), but in this case TYPE_NEEDS_CONSTRUCTING is still set only on the inner array (t) and not on TYPE_MAIN_VARIANT (t). A quick hack could be to dive recursively in cp_apply_type_quals_to_decl into ARRAY_TYPEs, as in: ... type_quals &= ~TYPE_QUAL_CONST; else for (; TREE_CODE (type) == ARRAY_TYPE; type = TREE_TYPE (type)) if (TYPE_NEEDS_CONSTRUCTNG (type) || TYPE_HAS_MUTABLE_P (type)) { type_quals &= ~TYPE_QUAL_CONST; break; } c_apply_type_quals_to_decl (type_quals, decl); or in complete_type looking at both t and its main variant: TYPE_NEEDS_CONSTRUCTING (type) = TYPE_NEEDS_CONSTRUCTING (t) || TYPE_NEEDS_CONSTRUCTING (TYPE_MAIN_VARIANT (t)); TYPE_HAS_NONTRIVIAL_DESTRUCTOR (type) = TYPE_HAS_NONTRIVIAL_DESTRUCTOR (t) || TYPE_HAS_NONTRIVIAL_DESTRUCTOR (TYPE_MAIN_VARIANT (t)); Note that complete_type doesn't update TYPE_NEEDS_CONSTRUCTING etc. for main variant, just for the type that has been requested. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24780