This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: Broken C array autosizing breaks glibc compile
- To: Franz Sirl <Franz dot Sirl-kernel at lauterbach dot com>
- Subject: Re: Broken C array autosizing breaks glibc compile
- From: Kaz Kylheku <kaz at ashi dot footprints dot net>
- Date: Thu, 21 Sep 2000 14:40:28 -0700 (PDT)
- cc: gcc-bugs at gcc dot gnu dot org, libc-alpha at sources dot redhat dot com
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''.