This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

[C++] Re: alpha bootstrap failure


On Fri, Apr 07, 2000 at 04:05:33PM -0700, Benjamin Kosnik wrote:
> /horton/bkoz/src.egcs/libstdc++-v3/src/complex.cc:34:
> /usr/include/bits/cmathcalls.h:120: Internal compiler error.
> /usr/include/bits/cmathcalls.h:120: Please submit a full bug report.

The compiler crashes in gperf-generated libc_name_p here:

     register const char * const *wordptr
	= &wordlist[TOTAL_KEYWORDS + lookup[offset]];

At issue is that `TOTAL_KEYWORDS' is a non-negative enum value,
and as such its signedness is implementation defined.  GCC chooses
`unsigned int' as the backing type.

The problem appears because `lookup[offset]' is type `short' and
in this instance has value -1, which is promoted to 0xffffffffu
in the arithmetic.  We then convert to ptrdiff_t to perform the
pointer arithmetic for the array index, and boom.

This is clearly a bug in gperf, however, it is possible to work
around the problem by not making TOTAL_KEYWORDS an enumeration
by removing `-E' from the gperf command-line.

Jason, do you have a preference for fixing the problem this way
or by patching gperf?


r~


	* Makefile.in (cfns.h): Remove -E from gperf command line.
	* cfns.h: Regenerate.

Index: Makefile.in
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/Makefile.in,v
retrieving revision 1.83
diff -c -p -d -r1.83 Makefile.in
*** Makefile.in	2000/04/06 00:51:23	1.83
--- Makefile.in	2000/04/08 00:44:55
*************** $(srcdir)/hash.h: $(srcdir)/gxx.gperf
*** 244,250 ****
  	exit 1 )
  
  $(srcdir)/cfns.h: $(srcdir)/cfns.gperf
! 	gperf -o -C -E -k '1-6,$$' -j1 -D -N 'libc_name_p' \
  		$(srcdir)/cfns.gperf > $(srcdir)/cfns.h
  
  spew.o : spew.c $(CXX_TREE_H) $(PARSE_H) $(srcdir)/../flags.h \
--- 244,250 ----
  	exit 1 )
  
  $(srcdir)/cfns.h: $(srcdir)/cfns.gperf
! 	gperf -o -C -k '1-6,$$' -j1 -D -N 'libc_name_p' \
  		$(srcdir)/cfns.gperf > $(srcdir)/cfns.h
  
  spew.o : spew.c $(CXX_TREE_H) $(PARSE_H) $(srcdir)/../flags.h \
Index: cfns.h
===================================================================
RCS file: /cvs/gcc/egcs/gcc/cp/cfns.h,v
retrieving revision 1.2
diff -c -p -d -r1.2 cfns.h
*** cfns.h	2000/04/04 20:46:23	1.2
--- cfns.h	2000/04/08 00:44:55
***************
*** 1,5 ****
! /* C code produced by gperf version 2.7 */
! /* Command-line: gperf -o -C -E -k 1-6,$ -j1 -D -N libc_name_p ../../../egcs-CVS20000404/gcc/cp/cfns.gperf  */
  #ifdef __GNUC__
  __inline
  #endif
--- 1,5 ----
! /* C code produced by gperf version 2.7.1 (19981006 egcs) */
! /* Command-line: gperf -o -C -k 1-6,$ -j1 -D -N libc_name_p ../../../../egcs-std/gcc/cp/cfns.gperf  */
  #ifdef __GNUC__
  __inline
  #endif
*************** static unsigned int hash PARAMS ((const 
*** 8,13 ****
--- 8,19 ----
  __inline
  #endif
  const char * libc_name_p PARAMS ((const char *, unsigned int));
+ 
+ #define TOTAL_KEYWORDS 207
+ #define MIN_WORD_LENGTH 3
+ #define MAX_WORD_LENGTH 10
+ #define MIN_HASH_VALUE 18
+ #define MAX_HASH_VALUE 1037
  /* maximum key range = 1020, duplicates = 1 */
  
  #ifdef __GNUC__
*************** libc_name_p (str, len)
*** 77,91 ****
       register const char *str;
       register unsigned int len;
  {
-   enum
-     {
-       TOTAL_KEYWORDS = 207,
-       MIN_WORD_LENGTH = 3,
-       MAX_WORD_LENGTH = 10,
-       MIN_HASH_VALUE = 18,
-       MAX_HASH_VALUE = 1037
-     };
- 
    static const char * const wordlist[] =
      {
        "gets",
--- 83,88 ----

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]