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

Bad instantiation of subclasses argument template with same name.


  I have sent to you ten days ago, under the same name
(, my whole project because it made the egcs
compiler crash. It was a big thing. It took me a whole week to understand
the bug location. I think this is the same bug in my previous project and
in this little program (600 bytes stripping comments).
  One week to find the bug... I have spend many time. I beg you to make
info file about bug reporting more compact. Although I understand why it
is so long.
  I think this is an important-to-fix bug : about bad evaluation of
argument template of subclasses whith the same name (here B). Please send
me the majordomo address to subscribe to.

						Vfdg (Daniel Goujot)

The first mail header :
Date: Tue, 11 Aug 1998 10:49:49 +0200 (MET DST)
From: Daniel Goujot <>
Subject: egcs-bug : a mystic one, skip it if you are busy.
   1 Shown    43 lines  Text
   2          14 KB     Application, "carre.Mon_Aug_10_19_09_18_CEST_1998.tar.gz"

--Forgive me for having sent that, please delete the first mail.
/* My laptop is a 2-month-old olivetti echos pro 150 dm. Installed :
Suse 5.2 / `uname -a` = Linux cem35 2.0.33 #64 Wed Apr 22 10:17:11 MEST 1998 i586 unknown
`g++ --version` = egcs-2.91.54
`which g++` = /usr/local/egcs/19980816/bin/g++
`date` = Mon Jul 27 20:45:53 CEST 1998
./configure --prefix=/usr/local/egcs        */

/* My script compiler :
{g++ -Wall -fguiding-decls essai.C && ./a.out } 2>&1 | sed ';s/\([0-9]*:\) /`\1'"'"' /' | less '-p^K`[^'"'"']*'"'"*/

/* My compiler's compaining :
test/bug.C`:' In function `void f<float>(const class C<long int> &, const class A<float> &)':
test/bug.C:`44:'   instantiated from here
In file included from essai.C:1:
test/bug.C:`27:' no matching function for call to `A<long int>::B::B (const A<float> &)'
test/bug.C:`27:' candidates are: A<long int>::B::B(const A<long int>::B &)
test/bug.C:`13:'                 A<long int>::B::B<long int>(const A<long int> &)

template<class T> class A
	T a_;
	A(const T & a=0) : a_(a) {};
	const T & value() const { return a_; }
	class B;
template<class T> class A<T>::B
	T b_;
	B(const A<T> & a) : b_(a.value()) {}
	void foobar() {}

template<class T> class C
	T c_;
	C(T c=0) : c_(c) {};
	const T & value() const { return a_; }
	class B;
	template<class U>
	friend void f(const C & c, const A<U> & a)
		// here is a bug source
		A<U>::B b(a);
		// The compiler seems to read `A<T>::B b(a);' :-( :-( :-(
		// writen so the g++ doesn't complain about unused variable
template<class T> class C<T>::B
	T b_;
	B(const C<T> & c) : b_(c.value()) {}

int main(void)
	A<float> a;
	C<long int> c;
	f(c, a);
	return 0;

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