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++/16232] New: Poor diagnostic


template<typename T> struct A {
    template<typename U> void Foo(){} };
template<typename V>struct B {
    void Bar(V* v) {
        v->template Foo<int>();
        v->Foo();
        }
    };
int main() {
    A<bool> a;
    B<A<bool> > b;
    b.Bar(&a);
    }

gets you:

~/ootbc/common/test/src$ g++ foo.cc
foo.cc: In member function `void B<V>::Bar(V*) [with V = A<bool>]':
foo.cc:12:   instantiated from here
foo.cc:6: error: no matching function for call to `A<bool>::Foo()'

As with many other g++ diagnostics, the error message is a true statement but not very helpful to the user. Something like:

"Call to 'A<bool>::Foo()' is ambiguous. Candidates are:
       foo.cc/6:  template<typename U> void Foo(){} };
May need explicit qualification of function name"

would help a lot.

FWIW, Comeau is not that much better:

"ComeauTest.c", line 6: error: no instance of function template
          "A<T>::Foo [with T=bool]" matches the argument list
            object type is: A<bool>
          v->Foo();
             ^
          detected during instantiation of
                    "void B<V>::Bar(V *) [with V=A<bool>]" at line 12

-- 
           Summary: Poor diagnostic
           Product: gcc
           Version: 3.4.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: igodard at pacbell dot net
                CC: gcc-bugs at gcc dot gnu dot org


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=16232


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