[cfe-dev] Showstopping behavior with atomic intrinsics

Benjamin Kramer benny.kra at gmail.com
Fri Sep 21 12:28:38 PDT 2012


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. There seems to be something wrong with the special handling code for __sync_ builtins in Sema.

- Ben



More information about the cfe-dev mailing list