From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 7E6C23858D35; Mon, 19 Feb 2024 18:15:07 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 7E6C23858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1708366507; bh=BoucFSkDVBxbr/cOWv1KBzbgUt/RRTXZe+eVZpGmJ8k=; h=From:To:Subject:Date:In-Reply-To:References:From; b=Hjh8oFHI9Eg7B57LB+yK1qgpNKrkCedoYGaiPOWYzcPyc7hnv+1LeY9TPYvFH9jns nm44TY+esLrOv/gLR28HPeTQfws32QlTWXIttEtSksfDPAmaxh3NRQzODfAdjXEiNQ WFuz5f9VJgONv6zGWsHdJPiHIqVUS3nsOBHAcBig= From: "ppalka 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 18:15:07 +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: ppalka 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 #10 from Patrick Palka --- (In reply to Jakub Jelinek from comment #8) > 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))) Maybe checking !DECL_TEMPLATE_INSTANTIATED would be better, since that's set only when the specialization's definition is instantiated from instantiate_= body as opposed to DECL_USE_TEMPLATE which gets set when the specialization is formed? > cp_apply_type_quals_to_decl (type_quals, decl); >=20=20 > 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_DECL grokdeclarator just looked up.=