[cfe-dev] Likely problem in canonical declaration

Douglas Gregor dgregor at apple.com
Mon Jan 18 12:44:15 PST 2010


On Jan 18, 2010, at 10:32 AM, Douglas Gregor wrote:

>
> On Jan 14, 2010, at 9:44 AM, Abramo Bagnara wrote:
>
>>
>> Compiling this snippet:
>>
>> void foo() {
>> int i;
>> __sync_fetch_and_add(&i, 1);
>> __sync_fetch_and_add(&i, 1);
>> }
>>
>> I get for builtin call to __sync_fetch_and_add_4 two different Decl*
>> and
>> although I found this a bit strange I've thought this is not a big
>> problem.
>>
>> What I think dangerous is that these two Decl* does not have neither
>> the
>> same value for getCanonicalDecl(), so I guess they're considered two
>> distinct functions.
>>
>> Do you confirm that this behaviour is symptom of a bug?
>
> Yes, this is the symptom of a bug. It's okay (but certainly not
> ideal!) to have two different Decl*'s for this builtin, but when there
> are multiple Decl*'s for the same thing, they must share the same
> canonical type. It looks like Sema::SemaBuiltinAtomicOverloaded needs
> to be taught to look for previous, compatible declarations of a given
> atomic builtin before building a new declaration.

I've filed this here:

	http://llvm.org/bugs/show_bug.cgi?id=6075

so we don't forget about it.

	- Doug



More information about the cfe-dev mailing list