https://gcc.gnu.org/bugzilla/show_bug.cgi?id=119138
--- Comment #2 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>: https://gcc.gnu.org/g:0ba3e5ff14a48f1fb7ca53cb86194e08d5b5da66 commit r15-7869-g0ba3e5ff14a48f1fb7ca53cb86194e08d5b5da66 Author: Jakub Jelinek <ja...@redhat.com> Date: Thu Mar 6 17:58:14 2025 +0100 c++: Fix up instantiation of pointer/reference/array types with attributes [PR119138] My r15-7822 PR118787 change unfortunately broke build on x86_64-w64-mingw32. The reduced testcase below shows what is going on. va_list on this target is char * with extra (non-dependent) attributes on it. Before my r15-7822 change, instantiation of such type used the fast path and just returned t, but as it has non-NULL TYPE_ATTRIBUTES, it now falls through, builds a pointer type and then calls apply_late_template_attributes. And in there triggers a bug, that function has been written for types with RECORD_TYPE/UNION_TYPE (or ENUMERAL_TYPE?) in mind, where we call apply_late_template_attributes with ATTR_FLAG_TYPE_IN_PLACE and can just apply the non-dependent attributes directly to TYPE_ATTRIBUTES. That is wrong for shared types like {POINTER,REFERENCE,ARRAY}_TYPE etc., we should just force cp_build_type_attribute_variant to build a variant type for the non-dependent attributes and then process dependent attributes (which given attr_flag will DTRT already). The second change in the patch is an optimization, we can actually return back to returning t even when TYPE_ATTRIBUTES is non-NULL, as long as it is non-dependent (dependent attributes are stored first, so it is enough to check the first attribute). 2025-03-06 Jakub Jelinek <ja...@redhat.com> PR c++/119138 * pt.cc (apply_late_template_attributes): Set p to NULL if ATTR_FLAG_TYPE_IN_PLACE is not set in attr_flags. (tsubst) <case POINTER_TYPE, case REFERENCE_TYPE, case ARRAY_TYPE>: Reuse original type even if TYPE_ATTRIBUTES is non-NULL, but all the attributes are non-dependent. * g++.dg/template/pr119138.C: New test.