From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id D1AE63858026; Thu, 31 Dec 2020 01:34:50 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D1AE63858026 From: "admin at maniacsvault dot net" To: gcc-bugs@gcc.gnu.org Subject: [Bug c++/98485] New: Symbols for identical constrained specializations have different linkage Date: Thu, 31 Dec 2020 01:34:50 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: c++ X-Bugzilla-Version: 10.2.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: admin at maniacsvault dot net 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: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone attachments.created Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Dec 2020 01:34:50 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D98485 Bug ID: 98485 Summary: Symbols for identical constrained specializations have different linkage Product: gcc Version: 10.2.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: admin at maniacsvault dot net Target Milestone: --- Created attachment 49861 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=3D49861&action=3Dedit Minimal example code When using multiple constrained specializations, the symbols generated have different linkage based on the order the specializations are defined in the file. The first specialization will generate weak symbols as expected, the second generates local symbols. See attached example. S1 is a structure containing a static member function= .=20 S2 and S3 differ in some way that's detectable through concepts. main.cpp = can only see these definitions so all it knows is that S1::f() is forward declared. a.cpp and b.cpp include s1-defs.h which contains two basically identical specializations of S1. The first is applied for S2, the second f= or S3. a.cpp instantiates S1. b.cpp instantiates S1. These do not n= eed to be separate files, this was just done to make it easier to diff the two outputs. What you will notice is that a.o contains an externally visible S1::f1 symbol. b.o contains a local S1::f1 symbol. Thus the progr= am can't link since main can't reference S1::f1. Despite there being basically no difference in the two specializations the linkage is unexpectedly different. If the order of the two specializations= in s1-defs.h is reversed then S1::f1 will become problematic. In s1-defs.h there's a USE_SINGLE define which when toggled uses if constex= pr instead of two specializations. This effectively works around the issue and the program links.=