This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/52291] New: __sync_fetch_and_add and friends poorly specified for pointer types
- From: "hstong at ca dot ibm.com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Fri, 17 Feb 2012 00:33:39 +0000
- Subject: [Bug c/52291] New: __sync_fetch_and_add and friends poorly specified for pointer types
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52291
Bug #: 52291
Summary: __sync_fetch_and_add and friends poorly specified for
pointer types
Classification: Unclassified
Product: gcc
Version: 4.6.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: hstong@ca.ibm.com
CC: michaelw@ca.ibm.com
Host: powerpc64-unknown-linux-gnu
Target: powerpc64-unknown-linux-gnu
The documentation states, regarding the __sync_fetch_and_X builtins:
These builtins perform the operation suggested by the name, and returns the
value that had previously been in memory. That is,
{ tmp = *ptr; *ptr op= value; return tmp; }
{ tmp = *ptr; *ptr = ~(tmp & value); return tmp; } // nand
For pointer types (which GCC accepts for these builtins) the "operation
suggested by the name" leans toward pointer arithmetic; however, the pointer
types are not suitable for these operations in C/C++.