Deprecating arithmetic on std::atomic<void*>

Jonathan Wakely jwakely@redhat.com
Thu Apr 20 09:18:00 GMT 2017


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.

Personally I'd be in favour of removing the extension for built-in
types too, but I doubt that would get consensus :-)



More information about the Libstdc++ mailing list