On Wed, 10 Nov 2010, Derek M Jones wrote:

> Julia,
> 
> > It also occurred to me that in eg sizeof(*x), where x has type int *, the
> > reference to *x is not really a reference to an integer value, and the
> > reference to x is not really a reference to an integer pointer value.
> > Thus there is no longer any type inference for the argument to sizeof.  If
> > this seems like a bad decision, please let me know and I will change it
> > back.
> 
> The following code is probably wrong:
> 
> char * ptr;
> 
> x=malloc(10*sizeof(ptr));
> 
> The intended argument to sizeof was probably *ptr
> Being able to match a pointer argument to sizeof is
> a useful thing to be able to do.

OK, this seems like a reaonsable example.  I will change it back.

> Another example is:
> 
> struct X x1, x2;
> struct Y y;
> 
> memcpy(&x1, &x2, sizeof(struct Y));
> 
> where the argument to sizeof has a type that is probably wrong.

This case is irrelevant.  The change only has an impact on whether 
Coccinelle keeps track of the types of expressions that appear in the 
argument to sizeof.  There is no expression in that context here.

julia
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to