public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Fwd: Re: Should atomic_xxx() functions reject not-_Atomic() arguments ?
       [not found] <afa29850-1cff-776e-7e66-3f13b0ccc97f@gmch.uk>
@ 2020-03-09 12:14 ` Chris Hall
  0 siblings, 0 replies; only message in thread
From: Chris Hall @ 2020-03-09 12:14 UTC (permalink / raw)
  To: gcc-help

On 08/03/2020 20:11, Martin Sebor wrote:
> On 3/7/20 6:04 AM, Chris Hall wrote:
...

>> I wonder if, by extension, the atomic_xxx() should (at least) warn 
>> when the _Atomic() parameters are passed not-_Atomic() arguments ?

> I think it would be useful to expose a command-line option in GCC
> to request a diagnostic for uses of the APIs with non-atomic types.
> Making it an error would probably not be a great solution because
> of the risk of breaking working code that has come to rely on it.

I guess existing code could continue to be compiled without the "revised 
API" option (and continue to work as well as it did before).  For 
new/updated code I think an error makes the point with suitable force. 
The programmer can always cast to _Atomic(), if they are confident that 
all their intended targets will work.  The "revised API" could also fix 
the fetch-add for pointers.

But...

>> As I have said elsewhere, I think the real problem is that the 
>> Standard fails to define vital things as Implementation Defined, 
>> leaving the programmer guessing as to what their code is going to do 
>> when compiled for some machine/system they are not familiar with.

...in particular: if I feel brave and cast (say) uint64_t to 
_Atomic(uint64_t), I don't have any obvious way to trigger a 
warning/error when compiling for a machine/system for which the cast is 
a grave mistake (for whatever reason).

Chris

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-03-09 12:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <afa29850-1cff-776e-7e66-3f13b0ccc97f@gmch.uk>
2020-03-09 12:14 ` Fwd: Re: Should atomic_xxx() functions reject not-_Atomic() arguments ? Chris Hall

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).