On Fri, 18 Feb 2005, Christopher Li wrote:
> 
> Another warning I did not fix is:
> ../pre-process.c:554:18: warning: bad constant expression
> The offending line is:
>       struct arg args[nargs];

Yeah, I should just allow that internally, and then just have a flag that 
enables the warning for kernel code. Sparse internally already has some 
support for a dynamic "array_size" (it _is_ a "struct expression *"), but 
to actually do the right thing is not trivial.

For example:

        int test(int n)
        {
                int array[n];
                return sizeof(n);
        }

should be trivial, right - just make "sizeof()" return the array entry 
size times the dynamic expression that we already have? Well, no, becuase:

        int test(int n)
        {
                int array[n];
                n = 9;
                return sizeof(array);
        }

so I'd really need to do a copy-expression, as the trivial implementation 
I initially had in mind would return 9*sizeof(int), which is obviously 
wrong.

But I could at least avoid the warning, and just warn on seeing the 
sizeof(), which sparse doesn't do right now.

                Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-sparse" in
the body of a message to [EMAIL PROTECTED]
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to