Likely problem in canonical declaration

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Likely problem in canonical declaration

Abramo Bagnara

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?


_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Likely problem in canonical declaration

Douglas Gregor

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.

        - Doug
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
Reply | Threaded
Open this post in threaded view
|

Re: Likely problem in canonical declaration

Douglas Gregor

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
_______________________________________________
cfe-dev mailing list
[hidden email]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev