From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ej1-x635.google.com (mail-ej1-x635.google.com [IPv6:2a00:1450:4864:20::635]) by sourceware.org (Postfix) with ESMTPS id CF7893858C01 for ; Wed, 23 Aug 2023 08:54:19 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org CF7893858C01 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ej1-x635.google.com with SMTP id a640c23a62f3a-99bdeae1d0aso712158466b.1 for ; Wed, 23 Aug 2023 01:54:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692780858; x=1693385658; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=bP3yeIsmi985PdYHuCWXwCEGuhE1CmwSBgM0T0rIbbQ=; b=HfXLB/pxg8H/hL9BVcG43KGhVVA6+HptogTZ1OLoZOq7invd8MbqGYTxWkUeUccw/Q fD80kbhuFvWlxkzbnTUNkopqRkvtygvC3FhUYxiGuR22I8cNujEqntgph+gBfDuRXJHX F3q5iPshLrKh+03P7/CKam3nEcXoaEzSmt1rho8741Bb5OHLj+HoKLBAQf142QKPOhxh 99MyG2VyBEiM/NsGlKjitIDbQs8u9Ted3BUiYtgy7kuTD+Qbx4z3Ry0SNHJ4w3RObsgX aC7ub8ogfet5D9kW7twlGf+TMVz15VWoa91LIv5qCmZvsRBQJpUEmNU7pygIXeeZYZSp WLsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692780858; x=1693385658; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bP3yeIsmi985PdYHuCWXwCEGuhE1CmwSBgM0T0rIbbQ=; b=N1HXyISnvRFHJRH6xVizzWy1/pNHCwPd3Fvv2jSZMVR1CMZCmHdp0ZWg+1DoaZV935 BmqDN/egso5sIamtuyCabERuhQM0vfbvL6pAgkz9x+djkzSXKir/RdZVfT2oY22f+yZV Toql8AHuyvzR4HasVCmdSpcLh8fNjDstR1hIKvjqP/l6NB8EIVqEUqr2q4n5z16nWytV PFdo+j0HKKTiab72Vnu/VBt7+JXlF84wulkncgDRFBZnscp1i5vt5al/4wcMFyWxBgmH m7YLy/sz3ldGBCRd+4RiIQvYbNhog7N2vzfrhC1dI77D2UxWa6w2Ypf/1onyOZRWwq5Z LuMg== X-Gm-Message-State: AOJu0Yzo7iLBk018Qriac0w/YSgKD0EM7iNB9EWKbYsL08cDpYQkYXBe l9veL9+S6qyrl1UkFpRVNtsKO6gV4Bv7gdeVPwE= X-Google-Smtp-Source: AGHT+IHiPQfHlcOjIn2uixW/Se8j8QzlzmNeOtfSJrjVrhW1By/YJBin9EByEFHfRDeEa9/febbqvOC+cuosoh/vMYY= X-Received: by 2002:a17:907:75f9:b0:99b:ed44:1a79 with SMTP id jz25-20020a17090775f900b0099bed441a79mr9899398ejc.3.1692780858069; Wed, 23 Aug 2023 01:54:18 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 23 Aug 2023 09:54:06 +0100 Message-ID: Subject: Re: RTTI names for classes in anonymous namespaces To: Varun Kumar E Cc: "libstdc++" Content-Type: multipart/alternative; boundary="000000000000ba57c10603934161" X-Spam-Status: No, score=-0.7 required=5.0 tests=BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM,HTML_MESSAGE,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: --000000000000ba57c10603934161 Content-Type: text/plain; charset="UTF-8" On Wed, 23 Aug 2023, 09:41 Varun Kumar E via Libstdc++, < libstdc++@gcc.gnu.org> wrote: > hello all, > > The RTTI names generated by gcc for classes in anonymous namespaces > begin with the prefix asterisk(*). > Once the __name pointer is different why do we not return > immediately? Instead we perform a string comparison if the name does not > begin with asterisk(*). > This would have been more more useful as a reply to your previous email on the subject (which I already replied to) rather than a separate thread. When using shared objects there is no guarantee that duplicate RTTI data gets combined, so we can have two or more copies of the data for a single type. Using strcmp to compare the names works correctly in this case. For types in anonymous namespaces (or types with no linkage) the type cannot exist in two different shared objects, so we know that the RTTI data is unique. That means a pointer comparison is ok. Could you please explain the reasoning behind this. > > code snippet below: > > type_info::operator==(const type_info& __arg) const _GLIBCXX_NOEXCEPT > { > if (std::__is_constant_evaluated()) > return this == &__arg; > > if (__name == __arg.__name) > return true; > > #if !__GXX_TYPEINFO_EQUALITY_INLINE > // ABI requires comparisons to be non-inline. > return __equal(__arg); > #elif !__GXX_MERGED_TYPEINFO_NAMES > // Need to do string comparison. > return __name[0] != '*' && __builtin_strcmp (__name, __arg.name > ()) > == 0; > #else > return false; > #endif > } > > Code link: typeinfo - gcc-mirror/gcc - Sourcegraph > < > https://sourcegraph.com/github.com/gcc-mirror/gcc/-/blob/libstdc++-v3/libsupc++/typeinfo?L205 > > > > > regards, > Varun > --000000000000ba57c10603934161--