Date: Sat, 14 Aug 1999 16:17:54 -0600
From: Richard Gooch <[EMAIL PROTECTED]>
Kurt Wall writes:
> Also sprach Richard Gooch:
> > Hi, all. I've just tried compiling some code on a RedHat 6.0 system,
> > and ran across a problem. I've written some test code that
> > demonstrates the problem:
> >
> > % cat egcs-example.c
> > #include <ctype.h>
> >
> > int func (char *array)
> > {
> > return tolower (array[0]);
> > }
> > % cc -c -Wall -pedantic-errors -O2 egcs-example.c
> > egcs-example.c: In function `func':
> > egcs-example.c:5: ANSI C forbids braced-groups within expressions
> > % gcc -v
> > Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/egcs-2.91.66/specs
> > gcc version egcs-2.91.66 19990314/Linux (egcs-1.1.2 release)
>
> It has to do with some interaction between -O2 optimization and tolower(),
> it appears. Behold, for the above code:
> $ gcc -c -Wall -pedantic-errors mtest.c
> $ gcc -c -Wall -pedantic-errors -O2 mtest.c
> mtest.c: In function `func':
> mtest.c:5: ANSI C forbids braced-groups within expressions
>
> In short, if you drop the -O2 optimization, it compiles. At least it
> did on my system.
Yes, I know. But that really isn't a solution. I don't want to compile
without optimisation. What I want is the bug in ecgs to be fixed.
Nope, that's not what you want. It is a bug in <ctype.h> which is a
libc header file.
What's happing is that when you compile with optimization (i.e. any
option that starts with -O) some functions are replaced by optimizing
macros and/or inline functions (look for __OPTIMIZE__ in the libc
header files). One of these functions is `tolower'. However, the
optimized version of `tolower' happens to use a gcc extension, and
therefore you get an error when you compile with -pedantic-errors.
The bug will be fixed in the next release of glibc (version 2.1.2).
If you cannot wait until the official release (which isn't too far
ahead) you could try to install the test release
(glibc-2.1.2pre2.tar.gz somewhere on your favourite ftp.kernel.org
mirror). Or you could fix the header file yourself by protecting the
__tobody code by __extension__. Or compile without -pedantic-errors!
Mark