public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/52291] New: __sync_fetch_and_add and friends poorly specified for pointer types
@ 2012-02-17 0:37 hstong at ca dot ibm.com
2012-02-17 0:41 ` [Bug c/52291] " redi at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: hstong at ca dot ibm.com @ 2012-02-17 0:37 UTC (permalink / raw)
To: gcc-bugs
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++.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/52291] __sync_fetch_and_add and friends poorly specified for pointer types
2012-02-17 0:37 [Bug c/52291] New: __sync_fetch_and_add and friends poorly specified for pointer types hstong at ca dot ibm.com
@ 2012-02-17 0:41 ` redi at gcc dot gnu.org
2012-02-17 1:00 ` hstong at ca dot ibm.com
2012-02-17 9:03 ` mikpe at it dot uu.se
2 siblings, 0 replies; 4+ messages in thread
From: redi at gcc dot gnu.org @ 2012-02-17 0:41 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52291
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> 2012-02-17 00:38:15 UTC ---
N.B. those built-ins are deprecated in favour of
http://gcc.gnu.org/onlinedocs/gcc/_005f_005fatomic-Builtins.html
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/52291] __sync_fetch_and_add and friends poorly specified for pointer types
2012-02-17 0:37 [Bug c/52291] New: __sync_fetch_and_add and friends poorly specified for pointer types hstong at ca dot ibm.com
2012-02-17 0:41 ` [Bug c/52291] " redi at gcc dot gnu.org
@ 2012-02-17 1:00 ` hstong at ca dot ibm.com
2012-02-17 9:03 ` mikpe at it dot uu.se
2 siblings, 0 replies; 4+ messages in thread
From: hstong at ca dot ibm.com @ 2012-02-17 1:00 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52291
--- Comment #1 from Hubert Tong <hstong at ca dot ibm.com> 2012-02-17 00:37:12 UTC ---
I mean that the pseudo-code is not consistent with valid C/C++ when the
operands (`*ptr' and `value') are pointer types.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug c/52291] __sync_fetch_and_add and friends poorly specified for pointer types
2012-02-17 0:37 [Bug c/52291] New: __sync_fetch_and_add and friends poorly specified for pointer types hstong at ca dot ibm.com
2012-02-17 0:41 ` [Bug c/52291] " redi at gcc dot gnu.org
2012-02-17 1:00 ` hstong at ca dot ibm.com
@ 2012-02-17 9:03 ` mikpe at it dot uu.se
2 siblings, 0 replies; 4+ messages in thread
From: mikpe at it dot uu.se @ 2012-02-17 9:03 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52291
--- Comment #3 from Mikael Pettersson <mikpe at it dot uu.se> 2012-02-17 08:53:28 UTC ---
(In reply to comment #1)
> I mean that the pseudo-code is not consistent with valid C/C++ when the
> operands (`*ptr' and `value') are pointer types.
I would think it's implied that the pointer values are automatically converted
to uintptr_t and that the bit-twiddling or arithmetic is done on their
uintptr_t representations.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2012-02-17 8:54 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-02-17 0:37 [Bug c/52291] New: __sync_fetch_and_add and friends poorly specified for pointer types hstong at ca dot ibm.com
2012-02-17 0:41 ` [Bug c/52291] " redi at gcc dot gnu.org
2012-02-17 1:00 ` hstong at ca dot ibm.com
2012-02-17 9:03 ` mikpe at it dot uu.se
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).