This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
g++ build failure (Was: C++ PATCH: PR 12735)
- From: Joern Rennecke <joern dot rennecke at superh dot com>
- To: mark at codesourcery dot com
- Cc: gcc-patches at gcc dot gnu dot org, gcc at gcc dot gnu dot org
- Date: Thu, 13 Nov 2003 15:58:31 +0000 (GMT)
- Subject: g++ build failure (Was: C++ PATCH: PR 12735)
> 2003-11-12 Mark Mitchell <mark@codesourcery.com>
>
> PR c++/12735
> * cp-tree.h (duplicate_decls): Return a tree.
> * decl.c (duplicate_decls): Clarify documentation. Return
> error_mark_node to indicate a failed redeclaration.
> * friend.c (do_friend): Handle that case.
> * name-lookup.c (pushdecl): Likewise.
This breaks the build on hosts with older versions of gcc
(independent of the target):
bash-2.05$ gcc -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/2.96/specs
gcc version 2.96 20000731 (Red Hat Linux 7.1 2.96-98)
gcc -c -g -O2 -DIN_GCC -DCROSS_COMPILE -W -Wall -Wwrite-strings -Wstrict-prototypes -Wmissing-prototypes -pedantic -Wno-long-long -fno-common -DHAVE_CONFIG_H -I. -Icp -I../../srcw/gcc -I../../srcw/gcc/cp -I../../srcw/gcc/../include ../../srcw/gcc/cp/decl.c -o cp/decl.o
... lots of warnings...
../../srcw/gcc/cp/decl.c: In function `grokfndecl':
... more warnings...
../../srcw/gcc/cp/decl.c:5696: incompatible types in assignment
../../srcw/gcc/cp/decl.c:5686: warning: `ok' might be used uninitialized in this function
... more warnings...
make[1]: *** [cp/decl.o] Error 1
make[1]: Leaving directory `/swbuild/nightly/2003-11-12/sh-elf/gcc'
In this compiler, _Bool is implemented by a header file as an enum,
which is not assignment-compatible with a pointer.
If my reading of the c99 standard is correct, although _Bool
exists in c99, it is not compatible with any pointer type, and
thus assigning a union tree_node * to ok is a constraint violation
of 6.5.16.1 .
I've tried compiling decl.i with the freshly-build cc1, and after
removing a __thread parameter name from a declaration that came from
/usr/include/bits/sigthread.h, it indeed compiles without even warning
about the assignment to ok.
Further experimentation shows that cc1 doesn't warn even if c89 or c99
is specifically requested.
bash-2.05$ cat boolass.c
char *bar ();
int
f()
{
_Bool i = bar ();
return i;
}
bash-2.05$ ./cc1 boolass.c -Wall -pedantic -std=c89
f
Execution times (seconds)
expand : 0.00 ( 0%) usr 0.00 ( 0%) sys 0.01 (50%) wall
TOTAL : 0.01 0.01 0.02
bash-2.05$ ./cc1 boolass.c -Wall -pedantic -std=c99
f
Execution times (seconds)
parser : 0.00 ( 0%) usr 0.01 (100%) sys 0.00 ( 0%) wall
TOTAL : 0.01 0.01 0.02
So we have two problems:
- g++ can only be build using a recent gcc version with a non-standard
extension. IIRC we require c89 for GCC source that is to be compiled
with the host compiler.
- gcc doesn't warn or error for using this extension, even when a standard
is selected that requires a diagnostic.