Mail Archives: djgpp/1997/12/30/14:15:48
In article <Chameleon DOT 971229204813 DOT nrotem AT netvision DOT netvision>, Noam
Rotem <nrotem AT johnbryce DOT co DOT il> writes
>I agree with you completely (and apologize for this long long
>responsa, but I might be missing something in this whole
>topic), but is there ANY possibility that someone will write
>this wrong code deliberately? If so, it should be a legal
>syntax, accompanied with a general warning for those who
>wrote it by mistake. But, if it is NEVER a correct syntax,
>and in no case it should be written, then let it be an error.
>Am I missing something?
>
>I'm referring, by the way, to the following code:
>
>int A[4][2]={{1,2,3,4},{5,6,7,8}};
Presumably, an error occurs when what has been input is definitely
wrong, or incomprehensible to the C compiler, in such a way that
compilation has to stop as there is no alternative. The example above,
although obviously wrong, is not really syntactically incorrect, is
meaningful C, and does not mean that compilation has to stop but just
that some of the array initializers will be discarded. gcc continues to
compile but lets you know anyway. Perhaps the main difference is how the
authors of the respective compilers think errors such as this should be
treated -- or maybe there is something in the ANSI standard about this
sort of thing.
--Tom
- Raw text -