This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c/68966] atomic_fetch_* on atomic_bool not diagnosed


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68966

Pon <pponnuvel at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pponnuvel at gmail dot com

--- Comment #7 from Pon <pponnuvel at gmail dot com> ---
Clarification needed about this change.

C standard says:

> None of these operations is applicable to atomic_bool.

I understand the "not applicable" as "because it's already an atomic type". But
does it also applicable to "plain" bool (_Bool) type too? GCC 6.1.1 with
-std=gnu99, GCC fails to compile and reports:

> error: operand type ‘_Bool *’ is incompatible with argument 1 of 
> ‘__sync_fetch_and_or’

for code that used to work with GCC 5.3.1. 

Comments from the testsuite:

> This is necessary because GCC expects that all initialized _Bool
> objects have a specific representation and allowing 
> atomic operations to change it would break the invariant.

and code:
> Those are not valid to call with a pointer to _Bool (or C++ bool)
> and so must be rejected.

suggest the change is deliberate for "plain" bool type (_Bool) too.
Does it mean the existing code that uses of these atomic intrinsics 
on plain bool type is buggy?

Obviously I can fix it by using an int/unsigned int instead
of _Bool or use atomic_bool in new code.
But my question is about GCC 6.1.1 breaking older code compiled
 using gnu99. I would appreciate a clarification on this.

Thanks.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]