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]
Other format: [Raw text]

[PCH] fix bug in typename_compare/typename_hash



I hit this build failure:

In file included from /louie/geoffk/gcc-pch-1/T-powerpc-eabisim/powerpc-eabisim/le/und/libstdc++-v3/include/string:57,
                 from /louie/geoffk/gcc-pch-1/T-powerpc-eabisim/powerpc-eabisim/le/und/libstdc++-v3/include/bits/localefwd.h:49,
                 from /louie/geoffk/gcc-pch-1/T-powerpc-eabisim/powerpc-eabisim/le/und/libstdc++-v3/include/ios:48,
                 from /home/geoffk/co/gcc-pch-1/gcc/libstdc++-v3/src/ios.cc:35:
/louie/geoffk/gcc-pch-1/T-powerpc-eabisim/powerpc-eabisim/le/und/libstdc++-v3/include/bits/basic_string.h:963: `
   std::basic_string<_CharT, _Traits, _Alloc>::size_type' is inaccessible
/louie/geoffk/gcc-pch-1/T-powerpc-eabisim/powerpc-eabisim/le/und/libstdc++-v3/include/bits/basic_string.tcc:51: within
   this context

Long, tedious investigation narrowed it down to the change to decl.c
to use htab_t hash tables.  It turned out to be a bug in the original
code; the hash function has

  hash = (((hashval_t) TYPE_CONTEXT (t))
	  ^ ((hashval_t) DECL_NAME (TYPE_NAME (t))));

but the comparison function uses 'same_type_p' to compare
TYPE_CONTEXT, which is not the same as pointer equality.
The previous hash code would rarely allow this to cause a difference,
the new hash code doesn't, and it happened to fail building ios.o for
the le/und multilib.

I'm pretty sure we need to do pointer comparison here, and certainly
that's effectively what we're doing now (most of the time).  Any other
opinions?

I'll eventually commit this if a powerpc-eabisim testrun passes.

-- 
Geoff Keating <geoffk@redhat.com>

===File ~/patches/pchbranch-typenamecmp.patch===============
2002-05-15  Geoffrey Keating  <geoffk@redhat.com>

	* decl.c (typename_compare): Don't use same_type_p.

Index: decl.c
===================================================================
RCS file: /cvs/gcc/gcc/gcc/cp/decl.c,v
retrieving revision 1.847.2.12
diff -p -u -p -r1.847.2.12 decl.c
--- decl.c	12 May 2002 06:11:49 -0000	1.847.2.12
+++ decl.c	16 May 2002 05:06:01 -0000
@@ -5523,7 +5523,7 @@ typename_compare (k1, k2)
   d2 = TYPE_NAME (t2);
 
   return (DECL_NAME (d1) == DECL_NAME (d2)
-	  && same_type_p (TYPE_CONTEXT (t1), TYPE_CONTEXT (t2))
+	  && TYPE_CONTEXT (t1) == TYPE_CONTEXT (t2)
 	  && ((TREE_TYPE (t1) != NULL_TREE)
 	      == (TREE_TYPE (t2) != NULL_TREE))
 	  && same_type_p (TREE_TYPE (t1), TREE_TYPE (t2))
============================================================


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