The following C++ code should not compile:

template<class T>
int t(T i)
{
  return f (i);  // error: f not visible here
}

int
f (int i)
{
  return i;
}

int
main()
{
  return t(1);
}

The C++ standard clause 14.6.3 states that names should be looked up from the
point they are used. I.e. functions defined after that point are not visible.
This is true for regular functions, but GCC does not get this right for
template functions.


-- 
           Summary: Bad name lookup for templates
           Product: gcc
           Version: 4.1.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: andrew dot stubbs at st dot com


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

Reply via email to