From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 14DAC3858D3C; Mon, 19 Feb 2024 17:30:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 14DAC3858D3C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708363813; bh=RccB73JDjux4DimCRoBvtV0XH/qi1rB1RXNALjadHnU=; h=From:To:Subject:Date:In-Reply-To:References:From; b=ZD+C+YsjiQLNu+GytZnMjVrLd7zwd5IZS3mhiuYXpACPTqIHESlEId0MWQavftP1k hOKOS7zdTw/31QpluBceLRn8JAsNVoBF5sGw09WV1METAN8f+/zTCAD6iR0YVXJbQC 1mm/93eBCeOzAWlVOduQUnoXXWGktl1Co1NvscwI= From: "jakub at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/113976] [11/12/13/14 Regression] explicit instantiation of const variable template following implicit instantiation is assembled in .rodata instead of .bss since r8-2857-g2ec399d8a6c9c2 Date: Mon, 19 Feb 2024 17:30:11 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 13.2.1 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: jakub at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 11.5 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113976 --- Comment #8 from Jakub Jelinek --- E.g. --- gcc/cp/decl.cc.jj 2024-02-15 09:51:34.460065992 +0100 +++ gcc/cp/decl.cc 2024-02-19 18:20:23.423410659 +0100 @@ -15263,7 +15263,14 @@ grokdeclarator (const cp_declarator *dec /* Record constancy and volatility on the DECL itself . There's no need to do this when processing a template; we'll do this for the instantiated declaration based on the type of DECL. */ - if (!processing_template_decl) + if (!processing_template_decl + /* Don't do it for instantiated variable templates either, + cp_apply_type_quals_to_decl should have been called on it + already and might have have been overridden in cp_finish_decl + if initializer needs runtime initialization. */ + && (!VAR_P (decl) + || DECL_LANG_SPECIFIC (decl) =3D=3D NULL + || !DECL_USE_TEMPLATE (decl))) cp_apply_type_quals_to_decl (type_quals, decl); return decl; fixes it, but it is just a random shot in the dark. I think we want to differentiate between freshly created VAR_DECL from the grokdeclarator vs. existing VAR_D= ECL grokdeclarator just looked up.=