[cfe-commits] [Request for review] Removing redundant implicit casts in the AST

Nicola Gigante nicola.gigante at gmail.com
Tue Oct 25 09:45:17 PDT 2011


Il giorno 25/ott/2011, alle ore 13:31, Abramo Bagnara ha scritto:

> 
> No, it is not useless because it is the reason why the decay has happened.
> 
> The agreed intention is to move toward a direction where we mark as NoOp
> only casts that has no effects (i.e. that can be removed without
> influencing neither parsing nor execution).
> 
> A cast whose presence is the reason why the array decay to pointer is
> done is not a redundant cast.
> 
> Of course the context should not be taken in consideration i.e. the
> expression should be considered in isolation.
> 
> int a[4];
> int *p;
> p = (int*)a;
> sizeof((int*)a);
> 
> Both array to pointer cast are relevant despite the fact that only in
> one case the context would have generated it nevertheless.
> 
> Do you think is a sensible approach?

I'm not sure, but I agree that this way the AST would be more consistent.
I'll try to see how to change this detail.

In the meantime, Doug what do you think?

Bye,
Nicola



More information about the cfe-commits mailing list