This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/12041] New: No overload search in evaluation of template parameter default value
- From: "raoulgough at yahoo dot co dot uk" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 23 Aug 2003 13:20:42 -0000
- Subject: [Bug c++/12041] New: No overload search in evaluation of template parameter default value
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12041
Summary: No overload search in evaluation of template parameter
default value
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: raoulgough at yahoo dot co dot uk
CC: gcc-bugs at gcc dot gnu dot org
GCC host triplet: i686-pc-mingw
How to reproduce. File overload.cc:
-----8<-------
struct A { };
struct B { };
char foo (A const &);
short foo (B const &);
template<typename T, unsigned Size = sizeof(foo(T()))>
struct bar {};
int main () {
bar<A>();
bar<B>();
}
-----8<-------
$ g++ -c overload.cc
overload.cc: In function `int main()':
overload.cc:11: error: could not convert `A()' to `const B&'
overload.cc:5: error: in passing argument 1 of `short int foo(const B&)'
overload.cc:11: error: template argument 2 is invalid
I think that this is *different* to bug 6424 and core language issue 339
because it does not involve any function template parameter deduction (and the
error message is different, too). It seems like g++ is only considering the
most recently seen version of foo(), since reversing the declaration order of
the two overloads produces a transposed error message:
short foo (B const &);
char foo (A const &);
// ...
overload.cc: In function `int main()':
overload.cc:12: error: could not convert `B()' to `const A&'
overload.cc:5: error: in passing argument 1 of `char foo(const A&)'
overload.cc:12: error: template argument 2 is invalid