This is the mail archive of the gcc-bugs@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]

Internal compiler error: name confusion in template?



  Using:

Reading specs from
/usr/local/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)

  The following code:

template <class Key> struct hash {
  void operator()(Key c) const {}
};

template <class Key, class Functor>
class Hash {
 public:

  void Add (Key k) {
	Functor f;
	f.hash (k);
  }

};

struct functor
{
  void hash (const char *k) const {
	::hash<const char *> hf;
	hf (k);
  }
};

main ()
{

  Hash<const char *,functor> Table;

  Table.Add ("Wibble");

}

  produces this:

g++ code.cc -o code
code.cc: In method `void Hash<const char *,functor>::Add<const char *,
functor>(const char *)':
code.cc:30:   instantiated from here
code.cc:12: Internal compiler error.
code.cc:12: Please submit a full bug report to
`egcs-bugs@egcs.cygnus.com'.
code.cc:12: See <URL:http://egcs.cygnus.com/faq.html#bugreport> for
details.

  changing the name of one of the hash functions so there is no clash
removes
the problem.


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