On compiling that code:
--- begin code ---
class Y {};
void f(Y*) { } // line 3. If comment - all ok
template < typename T>
void sel(T* a) { f(a); } //line 6
void f(void*) {}
int main(int argc, char **argv)
{
sel((void*)0); //line 12
}
--- end code ---
Àppears error:
../main.cpp: In function void sel(T*) [with T = void]:
../main.cpp:12: instantiated from here
../main.cpp:6: error: invalid conversion from void* to Y*
../main.cpp:6: error: initializing argument 1 of void f(Y*)
If comment line 3, then work.
Also work, if line 3 move after line 6.
If functions f(Y*), f(void*) and sel(T*) placed in different header files, then
arise dependency on order including headers.
--
Summary: Strangeness of name lookup in template function
Product: gcc
Version: 4.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rvovsd at mail dot ru
GCC host triplet: openSuse 10.3
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=34886