[Bug c++/31816] If a function foo is defined before declaring a template class A<T>, overloaded version of foo defined after the class declaration will not be available within class A<T>.

gael dot guennebaud at gmail dot com gcc-bugzilla@gcc.gnu.org
Tue Feb 2 20:44:00 GMT 2010



------- Comment #5 from gael dot guennebaud at gmail dot com  2010-02-02 20:44 -------
I hit the same issue, and according to c++ standard, here we have a _dependent_
lookup, and so the  qHash(int*) overloads should be found.

Here is an example directly taken from the C++ standard (14.6, #9):

#include <iostream>

void f(char) {std::cout << "char ";}

template<class T> void g(T t)
{
  f(1);      //   f(char)
  f(T(1));   //  dependent
  f(t);      //  dependent
}

void f(int) {std::cout << "int ";}

int main()
{
  g(2);    //  will cause one call of  f(char)  followed
           //  by two calls of  f(int)
  g('a');  //  will cause three calls of  f(char)
}

according to the c++ standard, the output should be:

char int int char char char

but gcc (4.x) returns:

char char char char char char

so, bug or non-bug ?


-- 

gael dot guennebaud at gmail dot com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |gael dot guennebaud at gmail
                   |                            |dot com


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



More information about the Gcc-bugs mailing list