This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Workaround bootstrap failure on RedHat 7.2
- From: Roger Sayle <roger at eyesopen dot com>
- To: gcc-patches at gcc dot gnu dot org
- Cc: Ben Elliston <bje at au1 dot ibm dot com>, Andrey Belevantsev <abel at ispras dot ru>
- Date: Mon, 2 Jan 2006 22:49:31 -0700 (MST)
- Subject: [PATCH] Workaround bootstrap failure on RedHat 7.2
Attempting to bootstrap mainline on a RedHat 7.2 system currently
fails with a fatal (-Werror) warning compiling decNumber.c during
stage2. The problem has been reported previously, and misdiagnosed
as an IA-64 specific issue here:
http://gcc.gnu.org/ml/gcc/2005-12/msg00699.html
The true source of the problem is a complicated macro expansion
in glibc's /usr/include/bits/string2.h header on the affected systems.
This results in the following diagnostic when instantiated:
../../trunk/libdecnumber/decNumber.c: In function 'decToString':
../../trunk/libdecnumber/decNumber.c:2013: warning: value computed is not used
Presumably, the correct fix is to use fixincludes to correct the
mistake in /usr/include/bits/string2.h, making it safe to use
strcpy with constant strings longer than 8 characters with -Werror.
It isn't clear whether this header needs to be corrected, or whether
the erroneous macro definitions in all the affected releases predate
GCC's built-in "strcpy" optimizations. This macro expansion is
particularly hairy and I'm particularly lazy, so I've investigated
two possible local work-arounds, in the hope that someone will take
up the gauntlet of a fixincludes-based patch [crosses fingers and
prepares for disappointment].
The first patch that fixes the bootstrap failure is to "#undef strcpy"
at the top of libdecnumber/decNumber.c after including <string.h>.
The second, and possibly more portable, workaround is to cast the
result of strcpy to void.
The following patch has been bootstrapped with a top-level "make
bootstrap", all default languages, on i686-pc-linux-gnu (RedHat 7.2),
and regression tested with a top-level "make -k check" with no new
failures.
Thoughts?
2006-01-02 Roger Sayle <roger@eyesopen.com>
* decNumber.c (decToString): Cast the result of strcpy to void,
to work around compilation warnings on broken glibc systems.
Index: decNumber.c
===================================================================
*** decNumber.c (revision 109243)
--- decNumber.c (working copy)
*************** decToString (decNumber * dn, char *strin
*** 2010,2016 ****
{ /* Is a special value */
if (decNumberIsInfinite (dn))
{
! strcpy (c, "Infinity");
return;
}
/* a NaN */
--- 2010,2016 ----
{ /* Is a special value */
if (decNumberIsInfinite (dn))
{
! (void) strcpy (c, "Infinity");
return;
}
/* a NaN */
Roger
--