This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/24657] bizarre diagnostic on valid (?) constructor
- From: "igodard at pacbell dot net" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 3 Nov 2005 16:43:02 -0000
- Subject: [Bug c++/24657] bizarre diagnostic on valid (?) constructor
- References: <bug-24657-6594@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- Comment #3 from igodard at pacbell dot net 2005-11-03 16:43 -------
Here's a reduced case:
template<int x> struct B {};
struct A {
template<int i>
A(const B<i>& b) : j(i) {}
void i() {}
int j;
};
int main() {
B<5> b;
A a(b);
}
which gets you:
~/ootbc/members/src$ g++ foo.cc
foo.cc: In constructor `A::A(const B<i>&) [with int i = 5]':
foo.cc:12: instantiated from here
foo.cc:5: error: argument of type `void (A::)()' does not match `int'
The compiler is picking up the member function "i" as the initializer for "j",
rather than the template argument "i". (In the original the template argument
"count" similarly matched a member function name). Yet it has the right "i" in
the constructor's argument type "B<i>", or there would have been an earlier
error.
FWIW, Comeau accepts this code.
Ivan
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24657