The test case below demonstrates two problems: 1) the line number in the error message points to an expression that involves only two ints (i.e., no object of T::BI as the message claims).
2) the program is well formed and the error is a regression from previous versions of the compiler. $ cat t.cpp && gcc -c t.cpp /* 1 */ struct A /* 2 */ { /* 3 */ A (int = 0); /* 4 */ operator int () const; /* 5 */ }; /* 6 */ /* 7 */ struct B /* 8 */ { /* 9 */ typedef int BI; /* 10 */ typedef A BA; /* 11 */ /* 12 */ }; /* 13 */ /* 14 */ template <class, class T> /* 15 */ struct C /* 16 */ { /* 17 */ typedef typename T::BA BA; /* 18 */ typedef typename T::BI BI; /* 19 */ /* 20 */ BA foo (BA ba) { /* 21 */ const int i = BI (ba); /* 22 */ /* 23 */ if (i < 0) /* 24 */ return A (); /* 25 */ /* 26 */ return A (); /* 27 */ } /* 28 */ }; /* 29 */ /* 30 */ template struct C<char, B>; t.cpp: In member function 'typename T::BA C< <template-parameter-1-1>, T>::foo(typename T::BA)': t.cpp:23: error: 'typename T::BI' used where a 'int' was expected -- Summary: bogus error on a user-defined conversion in a template Product: gcc Version: 4.0.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c++ AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: sebor at roguewave dot com CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: sparc-sun-solaris2.9 GCC host triplet: sparc-sun-solaris2.9 GCC target triplet: sparc-sun-solaris2.9 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21165