From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-ed1-x535.google.com (mail-ed1-x535.google.com [IPv6:2a00:1450:4864:20::535]) by sourceware.org (Postfix) with ESMTPS id 699323858C01 for ; Wed, 23 Aug 2023 09:00:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 699323858C01 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-ed1-x535.google.com with SMTP id 4fb4d7f45d1cf-52713d2c606so6905659a12.2 for ; Wed, 23 Aug 2023 02:00:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1692781209; x=1693386009; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=Cdj3xxW7agkIuL/H8St1FFcy8UGyqCwCdqC1WqSFW7Q=; b=L2dmvRJWKoF6zLFyvJBGVnhT8pI5CAEdHTbjaAtV8RcvBcpmTpt7cb3PWiOKlR/XYf 3Q+Q4oGNLq/BJ5mNNpwDPPHxFifoTSgx0XS9ihfbq+JWlcwnb3OIuYh52/bfk1aGSDkV oWIrg6C2fCVw4wZaaJiJm1vmIlVrAAcd56xm2uunlkcHOlE1e8ogpEATuTxjpNON5e+K Ey0l6nfmjufmeB5WP3HPm2jSxOBx2hqgQCOc4mebOqJrQAF0JEx29hDg7cF8w9L7SLd3 c6RHU4w9uicl6noETc/t2RUw2HQ/hdc8GfkvoIWi+2RG/1t7DQphd7nIEYaynUVajMC3 rFDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1692781209; x=1693386009; 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=Cdj3xxW7agkIuL/H8St1FFcy8UGyqCwCdqC1WqSFW7Q=; b=TENZG6vNeBz3Tvm6Nt6FPIAHrfOHmHiytj7vhLVz2sPvqeakhrurLDSnUhFjRsfA7n w1fPcpiE8gnSZuco58TUI90TNVgqg3IRtwtJDG8MeVWx+t6srvxLzHeummu2G8eLn7Mj LnusSZcS2MNzjCEpvYuidN9VtLPfCJRUZ1CsUMrQr+uFSNUJO+k5Csd2ynymFPWKw0l8 1izAg5PTBm+BUXjSa1PHWlU5XeKaIKVqPFaYyIT2IfkfdK015o1MXUBoufU9TauR6jYf O+7g4tNeHccI8yCGPO/5ra+tf/3p2KJgUbWfJDUMoIKQ2vdnYpi5lWNkYceRR7TbWX6F 8b9w== X-Gm-Message-State: AOJu0YwtBEheY7D0fw9cUTMwSZ/9HeyhHAR17rrtx+wFec9E8XCTHnps tymyOIHS3ei6O0UemkbpqcZ8mUB6N6evseQMKAo= X-Google-Smtp-Source: AGHT+IH9O50WNvrEXBhMn8GsDrBlM3B6dIK7/3Wo1uFToaw42PAwuyW0umKG+zsKRlY6KpdNaD0fdiEn4rlIg8AJryE= X-Received: by 2002:a17:907:7818:b0:99d:626f:adb with SMTP id la24-20020a170907781800b0099d626f0adbmr9491834ejc.58.1692781209223; Wed, 23 Aug 2023 02:00:09 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Jonathan Wakely Date: Wed, 23 Aug 2023 09:59:57 +0100 Message-ID: Subject: Re: RTTI names for classes in anonymous namespaces To: Varun Kumar E Cc: "libstdc++" Content-Type: multipart/alternative; boundary="000000000000a88cc806039356c1" X-Spam-Status: No, score=-0.6 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: --000000000000a88cc806039356c1 Content-Type: text/plain; charset="UTF-8" On Wed, 23 Aug 2023, 09:54 Jonathan Wakely, wrote: > > > 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. > And as I said in the other thread, the asterisk is present when the pointer comparison is ok. If either name begins with * then it's a type that only exists in one object file, and so its RTTI data is unique. > > 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 >> > --000000000000a88cc806039356c1--