From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 8765A3858C27; Thu, 6 Jul 2023 13:11:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 8765A3858C27 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1688649105; bh=0/WePvbZ7HLSs96y7MEVhdJPnUHm15Dir4vxUnyR0qY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=hR0pmddlb5Ck2Xh1Qb55b+h42WNOS1OIwt/CZvHer4DYePLtgq2VJF8+fyIQ5jofs jGyBK23Q67EN1el1Llh/ALdJ4YX44dZoH9Gb2SrqNfOYohPkPPa94X6plWsIKhmuhF wKBLA1Mn/WEEDO6YYqQUaJOn2Kj9IewiV3jeaNME= From: "redi at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libstdc++/110572] ld.lld: error: duplicate symbol: std::type_info::operator==(std::type_info const&) const Date: Thu, 06 Jul 2023 13:11:45 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libstdc++ X-Bugzilla-Version: unknown X-Bugzilla-Keywords: ABI X-Bugzilla-Severity: normal X-Bugzilla-Who: redi at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: 12.4 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: everconfirmed target_milestone cf_reconfirmed_on bug_status keywords 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=3D110572 Jonathan Wakely changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Target Milestone|--- |12.4 Last reconfirmed| |2023-07-06 Status|UNCONFIRMED |NEW Keywords| |ABI --- Comment #2 from Jonathan Wakely --- Prior to r12-6266-g3633cc54284450 making the definition in tinfo.cc inline would have meant it is never emitted into tinfo.o (unless __attribute__((us= ed)) was added to it). Since the __equal alias, the operator=3D=3D definition is always used, so i= t will still generate a symbol even if it's an inline function. But I'm not sure adding 'inline' there will actually fix anything. I still see it produce the same symbol whether inline or not: 0000000000000000 T _ZNKSt9type_info7__equalERKS_ 0000000000000000 T _ZNKSt9type_infoeqERKS_ I'm also concerned that the __equal function could end up in infinite recursion. If you compile C++20 code then the inline definition of type_info::operator=3D=3D in the header is used, which calls type_info::__e= qual, which is an alias for type_info::operator=3D=3D. If the alias doesn't bind = locally then it could call the inline definition from the header again, and recurse. I think a better fix would be to declare the operator=3D=3D in the header w= ith __attribute__((__always_inline__)). That will ensure there is never a symbol emitted for that inline definition, and so no multiple definition errors.=