This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/24657] bizarre diagnostic on valid (?) constructor



------- 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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]