[Cocci] sizeof() type
julia at diku.dk
Wed Nov 10 17:46:08 CET 2010
On Wed, 10 Nov 2010, Derek M Jones wrote:
> > 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;
> 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.
More information about the Cocci