This is the mail archive of the
mailing list for the libstdc++ project.
Re: Deprecating arithmetic on std::atomic<void*>
On 20/04/17 11:48 +0200, Florian Weimer wrote:
On 04/20/2017 11:39 AM, Jonathan Wakely wrote:
Or simply deprecate support for it in std::atomic. **If** the
extension for built-in types is useful then I can imagine it might be
useful to have it for std::atomic too, for a subset of the programs
relying on the original extension. But I'm unconvinced how useful
the original extension is. There are other ways to achieve it if
absolutely necessary, e.g. convert the void* to uintptr_t and perform
the arithmetic and use compare_exchange to store it back again.
GNU C programs routinely use pointer arithmetic on void *. I see less
need in C++ programs, simply because the use of void * is less common
And I see even less need to do it atomically.
Function pointer arithmetic is more tricky. A side effect of it is
that sizeof of a function type is defined as 1 (instead of a compiler
error or the actual size, in bytes, of the function in question).
This had the unintended consequence that it took years to spot that a
certain test for a non-executable stack was completely bogus (it
always crashed because only one byte of the function was copied to the
stack, and not the entire function). I don't know of any application