[cfe-dev] Showstopping behavior with atomic intrinsics

Abramo Bagnara abramo.bagnara at bugseng.com
Fri Sep 21 14:35:53 PDT 2012


Il 21/09/2012 21:28, Benjamin Kramer ha scritto:
> 
> On 21.09.2012, at 20:12, Abramo Bagnara <abramo.bagnara at bugseng.com> wrote:
> 
>> Reduced testcase:
>>
>> $ cat z.c
>> void f(volatile int* ptr, int val) {
>>  __sync_fetch_and_add_4(ptr, val);
>> }
>> void g(volatile int* ptr, int val) {
>>  __sync_fetch_and_add_4(ptr, val);
>> }
>> $ ~/llvm_trunk/Release+Asserts/bin/clang -c z.c
>> z.c:5:3: error: call to '__sync_fetch_and_add_4' is ambiguous
>>  __sync_fetch_and_add_4(ptr, val);
>>  ^~~~~~~~~~~~~~~~~~~~~~
>> z.c:2:3: note: candidate function
>>  __sync_fetch_and_add_4(ptr, val);
>>  ^
>> z.c:2:3: note: candidate function
>> 1 error generated.
>>
>> Removing g function the error disappears...
>>
>> As a side note I've noted this in Builtins.def:
>>
>> BUILTIN(__sync_fetch_and_add_4, "iiD*i.", "nt")
>>
>> The signature seems wrong to me: should not it be "iD*i."?
> 
> The signature looks right to me, the first "i" is the return type.

Stupid me! Of course you are right. I've been misleaded by comparison
with __sync_fetch_and_add signature.

> There seems to be something wrong with the special handling code for __sync_ builtins in Sema.

Do you have some idea about the causes of that?


-- 
Abramo Bagnara

BUGSENG srl - http://bugseng.com
mailto:abramo.bagnara at bugseng.com



More information about the cfe-dev mailing list