This is the mail archive of the
mailing list for the GCC project.
Re: Deprecating arithmetic on std::atomic<void*>
- From: Jonathan Wakely <jwakely at redhat dot com>
- To: Jakub Jelinek <jakub at redhat dot com>
- Cc: Florian Weimer <fweimer at redhat dot com>, gcc at gcc dot gnu dot org, libstdc++ at gcc dot gnu dot org
- Date: Thu, 20 Apr 2017 10:30:06 +0100
- Subject: Re: Deprecating arithmetic on std::atomic<void*>
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jwakely at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com CBAD265CFA
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com CBAD265CFA
- References: <20170419170736.GY3412@redhat.com> <firstname.lastname@example.org> <20170420091809.GA3412@redhat.com> <20170420092148.GO1809@tucnak> <20170420092540.GC3412@redhat.com>
On 20/04/17 10:25 +0100, Jonathan Wakely wrote:
On 20/04/17 11:21 +0200, Jakub Jelinek wrote:
On Thu, Apr 20, 2017 at 10:18:09AM +0100, Jonathan Wakely wrote:
On 20/04/17 08:19 +0200, Florian Weimer wrote:
On 04/19/2017 07:07 PM, Jonathan Wakely wrote:
> I know it's a bit late, but I'd like to propose deprecating the
> libstdc++ extension that allows arithmetic on std::atomic<void*>.
> Currently we make it behave like arithmetic on void*, which is also a
> GNU extension (https://gcc.gnu.org/onlinedocs/gcc/Pointer-Arith.html).
> We also allow arithmetic on types such as std::atomic<void(*)()> which
> is probably not useful (PR 69769).
Why is it acceptable to have the extension for built-in types, but not
for library types wrapping them? Why be inconsistent about this?
C++17 [atomic.types.pointer] paragraph 4 says:
Requires: T shall be an object type, otherwise the program is
ill-formed. [Note: Pointer arithmetic on void* or function pointers
is ill-formed. — end note]
That doesn't give us any leeway to support it.
Can't the support or lack thereof depend on -pedantic/-pedantic-errors?
In theory maybe.
I mean, with -pedantic-errors we already error on void * arighmetics
or function pointer arithmetics. If std::atomic<void*> would use
the void * arithmetics, it would also reject it. Or does it use integer
No, it does it on void*, but the __atomic built-ins still perform that
arithmetic even with -pedantic-errors.
If we can make the built-ins do the right thing then I'd be happy with
However, currently the built-ins treat all pointer arithmetic as void*
(or maybe char*, I'm not sure) i.e. arithmetic on T* ignores
sizeof(T). We already work around this in libstdc++, and PR 64843
points out <stdatomic.h> needs to do the same.