public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Jonathan Wakely <jwakely@redhat.com>
To: Stephan Bergmann <sbergman@redhat.com>
Cc: Thomas Rodgers <rodgert@appliantology.com>,
	Thomas Rodgers <trodgers@redhat.com>,
	 "libstdc++" <libstdc++@gcc.gnu.org>,
	gcc Patches <gcc-patches@gcc.gnu.org>,
	 Thomas Rodgers <rodgert@twrodgers.com>
Subject: Re: [PATCH] libstdc++: Implement C++20 atomic<shared_ptr> and atomic<weak_ptr>
Date: Mon, 17 Jan 2022 09:54:00 +0000	[thread overview]
Message-ID: <CACb0b4=JjJA_80Q9SC1WKS7FBZGoRGwcc4=1ET4G2S7cbCKezw@mail.gmail.com> (raw)
In-Reply-To: <893cd31c-d401-81d3-a8e3-55fd08abd9d2@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1401 bytes --]

On Mon, 17 Jan 2022 at 09:39, Stephan Bergmann <sbergman@redhat.com> wrote:

> On 1/17/22 01:12, Jonathan Wakely via Libstdc++ wrote:
> > Here's the finished version of that patch, which is all inline in the
> > header, and performs faster too.
> >
> > Tested powerpc64le-linux and x86_64-linux.
> > Pushed to trunk.
>
> FYI, recent Clang still requires typename in two places to compile
> <memory> with -std=c++20,
>
> > diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h
> b/libstdc++-v3/include/bits/shared_ptr_atomic.h
> > index 900499bae32..50aa46370ca 100644
> > --- a/libstdc++-v3/include/bits/shared_ptr_atomic.h
> > +++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h
> > @@ -456,8 +456,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
> >        typename _Tp::element_type* _M_ptr;
> >        _Atomic_count _M_refcount;
> >
> > -      static _Atomic_count::pointer
> > -      _S_add_ref(_Atomic_count::pointer __p)
> > +      static typename _Atomic_count::pointer
> > +      _S_add_ref(typename _Atomic_count::pointer __p)
> >        {
> >       if (__p)
> >         {
>

Sigh, yes, I already noticed this myself. Clang is wrong (P0634R0 gives an
example *very* similar to this as motivation for the change), but we need
to keep writing the code in C++17 style if we want to be compatible with
released versions of Clang.

Fixed by the attached patch, tested x86_64-linux and pushed to trunk.

[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 953 bytes --]

commit a923345c72aef9ebb6b32f81f4825acc11085803
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Mon Jan 17 09:42:35 2022

    libstdc++: Add 'typename' to dependent types in atomic<shared_ptr<T>>
    
    libstdc++-v3/ChangeLog:
    
            * include/bits/shared_ptr_atomic.h (_Sp_atomic): Add typename
            to qualified-id for dependent type.

diff --git a/libstdc++-v3/include/bits/shared_ptr_atomic.h b/libstdc++-v3/include/bits/shared_ptr_atomic.h
index 900499bae32..50aa46370ca 100644
--- a/libstdc++-v3/include/bits/shared_ptr_atomic.h
+++ b/libstdc++-v3/include/bits/shared_ptr_atomic.h
@@ -456,8 +456,8 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
       typename _Tp::element_type* _M_ptr;
       _Atomic_count _M_refcount;
 
-      static _Atomic_count::pointer
-      _S_add_ref(_Atomic_count::pointer __p)
+      static typename _Atomic_count::pointer
+      _S_add_ref(typename _Atomic_count::pointer __p)
       {
 	if (__p)
 	  {

  reply	other threads:[~2022-01-17  9:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-17 17:51 Thomas Rodgers
2021-09-18  4:01 ` Thomas Rodgers
2022-01-14 22:40   ` Jonathan Wakely
2022-01-17  0:12     ` Jonathan Wakely
2022-01-17  9:39       ` Stephan Bergmann
2022-01-17  9:54         ` Jonathan Wakely [this message]
2022-01-18 18:04 David Edelsohn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACb0b4=JjJA_80Q9SC1WKS7FBZGoRGwcc4=1ET4G2S7cbCKezw@mail.gmail.com' \
    --to=jwakely@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=rodgert@appliantology.com \
    --cc=rodgert@twrodgers.com \
    --cc=sbergman@redhat.com \
    --cc=trodgers@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).