On Thu, Nov 04, 2010 at 17:06 +0100, Julia Lawall wrote:
> On Thu, 4 Nov 2010, Vasiliy Kulikov wrote:
> > IMO it should catch all C99 arrays, correct?
>
> I'm not an expert on what a C99 array is. But if it is the case where the
> size is not a constant,
Exactly.
> then this looks fine.
> I think you don't really
> need TT. You could just say constant s, unless you need the type for
> something else.
Correct, thank you.
> > Obviously 1+1 is constant :)
>
> I think this is something that has gone back and forth. Is it a big
> problem in practice?
Actually, I want to inspect all C99 array usages as they might be
dangerous if array size is not correctly checked. If 1+1 is not
constant, I would get just more code to manually check. It's not
horrible, but I'd want to avoid it ;)
Do you mean that to implement it properly you have to change too many
boring cases of arithmetic operators? If so, don't trouble yourself.
Also, defined constant is not constant too:
--- main.c 2010-11-04 19:04:39.000000000 +0300
+++ /tmp/cocci-output-16573-ef1775-main.c 2010-11-04
19:04:41.000000000 +0300
@@ -11,9 +11,6 @@ main(int argc, char **argv)
{
int s = 2;
int a[sizeof(int)];
- int b[s];
- int c[1+1];
#define size 1
- int d[size];
return 0;
}
--
Vasiliy
_______________________________________________
Cocci mailing list
[email protected]
http://lists.diku.dk/mailman/listinfo/cocci
(Web access from inside DIKUs LAN only)