On Thu, 4 Nov 2010, Vasiliy Kulikov wrote:

> Hi,
> 
> I found that integer constants don't always have proper type:
> 
> @@
> int x;
> @@
> 
> *x
> 
> --- main.c  2010-11-04 20:22:43.000000000 +0300
> +++ /tmp/cocci-output-21349-91c3d8-main.c   2010-11-04
> 20:22:47.000000000 +0300
> @@ -9,5 +9,4 @@
>  int
>  main(int argc, char **argv)
>  {
> -    18446744073709551615;
>  }
> 
> 
> $ bc <<EOF
> > 256^8-1
> > EOF
> 18446744073709551615
> 
> 
> This big constant should be of type "unsigned long".
> 
> http://www.wattpad.com/178243?p=76
> (A.2.5.1 Integer constants)
> 
> The type should depend on
> 
> (a) constant's prefix and suffix

This should be the case.  If you see a problem, please let me know.

> (b) architecture-dependent sizeof(int)

I would have no idea how to do this, because Coccinelle is not necessarily 
run on the architecture that the code is associated with.  Perhaps the 
number of bits in an int could be a command line argument.

julia

> I don't know how to correctly and beautifilly implement (b) :(
> 
> 
> Even if it cannot be fully implemented, partial (e.g. architecture
> independent) implementation is also damn good - it should detect
> different non-obvious integer overflows.
> 
> 
> Thanks,
> 
> -- 
> Vasiliy
> _______________________________________________
> Cocci mailing list
> [email protected]
> http://lists.diku.dk/mailman/listinfo/cocci
> (Web access from inside DIKUs LAN only)
> 
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)

Reply via email to