Broken C array autosizing breaks glibc compile
Kaz Kylheku
kaz@ashi.footprints.net
Thu Sep 21 14:40:00 GMT 2000
On Thu, 21 Sep 2000, Franz Sirl wrote:
> Date: Thu, 21 Sep 2000 23:18:46 +0200
> From: Franz Sirl <Franz.Sirl-kernel@lauterbach.com>
> To: gcc-bugs@gcc.gnu.org
> Cc: libc-alpha@sources.redhat.com
> Subject: Broken C array autosizing breaks glibc compile
>
> Hi,
>
> with current CVS gcc at least PPC and alpha have problems with compiling a
> locale test in the glibc testsuite. Inspection shows that gcc miscompiles
> this routine:
[ snip ]
> static const struct keyword_t *
> repertoiremap_hash (const char *str, unsigned int len)
> {
> static const struct keyword_t wordlist[0] =
This is not valid C. In C, arrays must have a positive size.
Unfortunately, gcc only diagnoses this error if you give it -pedantic:
warning: ANSI C forbids zero-size array `wordlist'
> So wordlist is never initialized :-(. If I change the wordlist[0] to
What does it mean to initialize a zero-length object?
The only reasonable thing would be for the compiler to emit a diagnostic, like
``too many elements in initializer for array dimension''.
More information about the Libc-alpha
mailing list