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
(b) architecture-dependent sizeof(int)


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)

Reply via email to