Bug 41639 - synchronisation primitives take unsigned as input and output values.
synchronisation primitives take unsigned as input and output values.
Status: UNCONFIRMED
Product: gcc
Classification: Unclassified
Component: middle-end
4.5.0
: P3 trivial
: ---
Assigned To: Not yet assigned to anyone
:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2009-10-09 07:06 UTC by chrbr
Modified: 2010-07-20 22:21 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Fix synchronisation parameter/output signess (1.12 KB, patch)
2009-10-09 07:12 UTC, chrbr
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description chrbr 2009-10-09 07:06:16 UTC
Current implementation of the synchronization builtins in gcc (from http://software.intel.com/sites/products/documentation/hpc/compilerpro/en-us/cpp/lin/compiler_c/intref_cls/common/intref_itanium_synchro_prim.htm) describe <type> as unsigned. although it is stated as "<type> is either a 32-bit or 64-bit integer"

consequently, testsuite tests such as sync-2.c:

if (__sync_sub_and_fetch(AI+13, 12) != (char)-12)
    abort ();

might fail. (unless the target/runtime dependant primitive implementation artificially change the return type).
Comment 1 chrbr 2009-10-09 07:12:40 UTC
Created attachment 18758 [details]
Fix synchronisation parameter/output signess

The attached patch gives the correct semantic. But should be checked on target using them (pa/arm) for possible legacy regression.

(tested on SH with a non-linux, in house runtime, implementation)

2009-10-08  Christian Bruel  <christian.bruel@st.com>
 
	* builtin-types.def (BT_I[1,2,4,8,16): Set signed.
Comment 2 Steven Bosscher 2010-07-20 22:21:38 UTC
Mis-categorized as a treelang bug (?!).

rth, you added these primitive types and the _sync_* builtins... Could you have a look at this bug and at the patch of comment #1, please?