This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Default arg changes signature of function
- To: egcs-bugs at cygnus dot com
- Subject: Default arg changes signature of function
- From: Wolfgang Bangerth <wolf at gaia dot IWR dot Uni-Heidelberg dot De>
- Date: Tue, 27 Apr 1999 13:01:03 +0200 (MET DST)
Hi there,
the following little program produces suprising results: depending on
whether a parameter to a function has a default value or not, it matches a
function pointer type or not:
-------------------------------------------
class X {
public:
template <class number> void x (number i1);
template <class number> void y (number i1=1);
};
void f () {
typedef void (X:: * Xptr) ();
Xptr xptr;
xptr = & X::template x<int>; // this one fails
xptr = & X::template y<int>; // this one is accpeted
};
-------------------------------------
The output of gcc -v is:
-------------------------------------
> gcc -v -c a.cc
Reading specs from
/usr/local/gcc/egcs-1.1.2/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.66/specs
gcc version egcs-2.91.66 19990314 (egcs-1.1.2 release)
/usr/local/gcc/egcs-1.1.2/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.66/cpp
-lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus
-D__GNUC_MINOR__=91 -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) a.cc /var/tmp/ccnWoXTi.ii
GNU CPP version egcs-2.91.66 19990314 (egcs-1.1.2 release) (sparc)
#include "..." search starts here:
#include <...> search starts here:
/usr/local/gcc/egcs-1.1.2/include/g++
/usr/local/include
/usr/local/gcc/egcs-1.1.2/sparc-sun-solaris2.6/include
/usr/local/gcc/egcs-1.1.2/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.66/include
/usr/include
End of search list.
/usr/local/gcc/egcs-1.1.2/lib/gcc-lib/sparc-sun-solaris2.6/egcs-2.91.66/cc1plus
/var/tmp/ccnWoXTi.ii -quiet -dumpbase a.cc -version -o /var/tmp/cczrNT3I.s
GNU C++ version egcs-2.91.66 19990314 (egcs-1.1.2 release)
(sparc-sun-solaris2.6) compiled by GNU C version egcs-2.91.60 19981201
(egcs-1.1.1 release).
a.cc: In function `void f()':
a.cc:12: cannot resolve overload to target type `void (X::)()'
a.cc:12: because no suitable overload of function `x' exists
-------------------------------------
Note the missing error on line 13.
Anyway, many thanks for all your efforts in egcs, which I consider the
most important free software product!
Best regards
Wolfgang
-------------------------------------------------------------------------
Wolfgang Bangerth email: wolf@gaia.iwr.uni-heidelberg.de
www: http://gaia.iwr.uni-heidelberg.de/~wolf