eg++ confusion with template argument
Wolfgang Bangerth - home account
wolf@gaia.iwr.uni-heidelberg.de
Tue Jun 30 21:29:00 GMT 1998
Hi there,
this struck me when trying to compile a large project which compiled fine
with gcc 2.8, but didn't with egcs-ss-19980621:
----------------------------test1.cc-------------------------------------
template <int dim>
class Point {
public:
Point (Point<dim> &);
Point<dim> & operator = (Point<dim> &);
};
template <int dim>
class bar{
public:
void foo (Point<dim> p = Point<dim>());
};
template <>
void bar<2>::foo (Point<2> p) {
const int dim = 2;
Point<dim> q = p;
};
--------------------------------------------------------------------------
The problem seems to be that eg++ can't properly deduce the types of the
involved Point<>'s from the constant value 'dim':
---------------------Output----------------------------------------------
Reading specs from
/home/wolf/bin/egcs-19980621/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.42/specs
gcc version egcs-2.91.42 19980621 (gcc2 ss-980502 experimental)
/home/wolf/bin/egcs-19980621/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.42/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=91 -D__ELF__ -Dunix -Dlinux -D__ELF__ -D__unix__
-D__linux__ -D__unix -D__linux -Asystem(posix) -D__EXCEPTIONS -Di386
-Asystem(unix) -Acpu(i386) -Amachine(i386) -D__pentium__ -D__i586__
-D__i386__ -Asystem(unix) -Acpu(i386) -Amachine(i386) -D__pentium__
-D__i586__ test1.cc /tmp/cca23031.ii
GNU CPP version egcs-2.91.42 19980621 (gcc2 ss-980502 experimental) (i386
Linux/ELF)
#include "..." search starts here:
#include <...> search starts here:
/home/wolf/bin/egcs-19980621/include/g++
/usr/local/include
/home/wolf/bin/egcs-19980621/i586-pc-linux-gnulibc1/include
/home/wolf/bin/egcs-19980621/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.42/include
/usr/include
End of search list.
/home/wolf/bin/egcs-19980621/lib/gcc-lib/i586-pc-linux-gnulibc1/egcs-2.91.42/cc1plus
/tmp/cca23031.ii -quiet -dumpbase test1.cc -version -o /tmp/cca23031.s
GNU C++ version egcs-2.91.42 19980621 (gcc2 ss-980502 experimental)
(i586-pc-linux-gnulibc1) compiled by GNU C version egcs-2.91.42 19980621
(gcc2 ss-980502 experimental).
test1.cc: In method `void bar<2>::foo<2>(class Point<2> = Point<dim>())':
test1.cc:21: no matching function for call to `Point<dim>::Point(Point<dim>)'
test1.cc:4: candidates are: Point<dim>::Point<2>(Point<2> &)
-----------------------------------------------------------------------------
If I comment out the two lines in the Point class (which should not change
a thing, since the functions should be generated automatically), the
output looks like this:
-------------------------Output 2----------------------------------------
test1.cc: In instantiation of `Point<dim>':
test1.cc:19: instantiated from here
test1.cc:19: type `Point<2>' is not a base type for type `Point<dim>'
test1.cc:19: common_type called with uncommon aggregate types (compiler error)
test1.cc:19: confused by earlier errors, bailing out
-------------------------------------------------------------------------
Regards,
Wolfgang
More information about the Gcc-bugs
mailing list