This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
egcs 1.0.3 bug (?) promoting to template type
- To: egcs-bugs at cygnus dot com
- Subject: egcs 1.0.3 bug (?) promoting to template type
- From: Gregory Bond <gnb at itga dot com dot au>
- Date: Wed, 01 Jul 1998 09:38:19 +1000
egcs 1.0.3a, Sun Sparc E450, Solaris 2.6, --with-gnu-ld
The following code works as expected:
-------------
struct A
{
A();
A(int);
friend bool operator==(const A&, const A&);
};
int
main()
{
A a(2);
return a == 1;
}
--------------
i.e. the constant 1 is promoted to a type A and the op==(A, A) is called.
The template equivalent to that (if I've understood the nuances of this bit of
the new standard correctly - which is a definite maybe!) gets surprising
results:
--------------
class A;
bool operator==(const A&, const A&);
template <class T> struct B;
template <class T>
bool operator==(const B<T>&, const B<T>&);
template <class T>
struct B
{
B();
B(int);
friend bool operator== <>(const B&, const B&);
};
int
main()
{
B<bool> b(2);
return b == 1;
}
/*
lightning$ g++ -v -c tt5.C
Reading specs from /usr/local/egcs/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.90.29/specs
gcc version egcs-2.90.29 980515 (egcs-1.0.3 release)
/usr/local/egcs/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.90.29/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -D__GNUC_MINOR__=90 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__ -D__sun__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix) -Asystem(svr4) -D__EXCEPTIONS -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) tt5.C /var/tmp/cc0yUPSV.ii
GNU CPP version egcs-2.90.29 980515 (egcs-1.0.3 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/egcs/include/g++
/usr/local/include
/usr/local/egcs/sparc-sun-solaris2.6/include
/usr/local/egcs/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.90.29/include
/usr/include
End of search list.
/usr/local/egcs/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.90.29/cc1plus /var/tmp/cc0yUPSV.ii -quiet -dumpbase tt5.cc -version -o /var/tmp/cc0yUPSV.s
GNU C++ version egcs-2.90.29 980515 (egcs-1.0.3 release) (sparc-sun-solaris2.6) compiled by GNU C version egcs-2.90.29 980515 (egcs-1.0.3 release).
tt5.C: In function `int main()':
tt5.C:21: no match for `B<bool> & == int'
tt5.C:2: candidates are: operator ==(const A &, const A &)
*/
--------------------