From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id F09C63858D20; Tue, 11 Apr 2023 06:16:12 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F09C63858D20 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681193772; bh=s/sHhBuwwOPRu/vbOJmfdA4t/35TaXvedu6FUC5Dmiw=; h=From:To:Subject:Date:In-Reply-To:References:From; b=jlQYEqN0ElodSs92WfbOI5T+l736xbDoZfEDquow5Qj1TlwmnGKOKOF5WZBZQfhPe 9Xzp+8V4hfX4xw6TxnTM5MI+u1DXfPGEYzBhaz1NB0r2LHwUCdAAzPdkBR/WXtpOSJ 5qIRBJ8s9uBxtFu4EbM6O9QNQXJSPz9Ca4xncjA4= From: "lh_mouse at 126 dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/109464] gcc does not instantiate constructor for explicitly instantiated template Date: Tue, 11 Apr 2023 06:16:12 +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: 12.2.0 X-Bugzilla-Keywords: link-failure X-Bugzilla-Severity: normal X-Bugzilla-Who: lh_mouse at 126 dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- 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=3D109464 --- Comment #5 from LIU Hao --- Additional information: I tried splitting the two class templates into two separate .cpp files, so = the explicit instantiation of `basic_shallow_string` should not be subjec= t to the instantiation of `basic_cow_string`. This made GCC emit the constructor correctly (checked by examining assembly), but still failed to = the very same undefined reference. At the moment, a temporary workaround is to mark the constructor of `basic_shallow_string` as `always_inline`. This works for GCC 10, 11 and 12. Haven't checked GCC 9 as it's no longer available from APT sources of my current machine.=