I think this is a compiler bug.  But I'm willing to bet that
if you swap the order of the two initializations, it'll work.
I suspect that tcc records the size of the first array used with
that time, and then expects subsequent arrays to be the same
size or smaller.

HTH,

Arnold

Freelance Roemke <[email protected]> wrote:

>
> Hi,
>
> I just tried to compile a 35 year old code (not from me) that looks 
> similar to
>
> cat <<-KWC > kw.c
> #include <stdio.h>
>
> typedef    char    *keywords[];
>
> extern    keywords    ord2kw;
> extern    keywords    ord3kw;
>
> keywords ord2kw= {
>      "E", "L", NULL
> };
>
>
> keywords ord3kw= {
>      "D", "T", "I",
>      "D2", "T2", "I2", "P",
>      "P2", "V", NULL
> };
>
>
> int main()
> {
>      printf("%u\n",sizeof ord2kw);
>      printf("%u\n",sizeof ord3kw);
> }
> KWC
>
> and while all the gcc and clang version since then have compiled it and 
> also used a different size for ord2kw and ord3kw, tcc now tells me
>
> kw.c:16: error: too many initializers
>
> and only if both ord2kw and ord3kw have the same number of elements, the 
> error message disappears.
>
>
>
> Could anyone enlighten me the reason for that, maybe with a reference to 
> the C89 or C99 standard?
>
>
> As far as I read the C99 standard, e.g., it says
>
> /6.7.8 22 If an array of unknown size is initialized, its size is 
> determined by the largest indexed
> element with an explicit initializer. At the end of its initializer 
> list, the *array* no longer
> has incomplete type.
> /
> but IMHO this does not mean that the *type* (here keywords) no longer 
> has an incomplete type.
>
>
> And is there an option to change that behaviour?
>
>
> Thomas
>
>
>

_______________________________________________
Tinycc-devel mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to