So? Gcc does that anyway. _Any_ good compiler has to.
And if the compiler isn't good enough to do it, then the compiler
shouldn't be warning about something that it hasn't got a clue about.
> |> and anybody who writes 'array[5UL]' is considered a stupid git and a
> |> geek. Face it.
>
> But array[-1] is wrong. An array can never have a negative index (I'm
> *not* talking about pointers).
You're wrong.
Yes, when declaring an array, you cannot use "array[-1]". But that's not
because the thing is unsigned: the standard says that the array
declaration has to be a "integer value larger than zero". It is not
unsigned: it's _positive_.
However, in _indexing_ an array (as opposed to declaring it), "array[-1]"
is indeed perfectly fine, and is defined by the C language to be exactly
the same as "*(array-1)". And negative values are perfectly fine, even for
arrays. Trivial example:
int x[2][2];
int main(int argc, char **argv)
{
return x[1][-1];
}
the above is actually a well-defined C program, and 100%
standards-conforming ("strictly conforming").
Linus
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/