On 09/25/2012 02:46 PM, Liviu Nicoara wrote:
I filed 1070, failure to build 22.locale.collate.cpp on Linux with gcc
4.7.1. Gcc, Comeau and Clang fail to compile it, Intel and Sun are fine.
It looks to me like Intel and Sun compilers are not doing the right
thing. A small test case and a patch have been attached. The failing
code has been reduced to:


I agree that the test case is ill-formed and requires a diagnostic.

I haven't looked at the test so just to make sure the test case does
reflect the problem there: the well-formedness depends on whether
charT is a class type. If so, then the code would be okay because g()
would be found via associated namespace lookup. I.e., this would be
fine:

  template <class charT>
  void f () { g (charT ()); }

  template <class charT>
  void g (charT) { }

  struct S { };

  void h () { f<S>(); }

Martin


$ cat test.cpp; g++ -c test.cpp
template < class charT >
void f ()
{
g (charT ('a'));
}

template < class charT >
void g (charT)
{
}

int h ()
{
return f< char > (), 0;
}
test.cpp: In instantiation of 'void f() \[with charT = char\]':
test.cpp:14:23: required from here
test.cpp:4:5: error: 'g' was not declared in this scope, and no
declarations were found by argument-dependent lookup at the point of
instantiation \[-fpermissive\]
test.cpp:8:6: note: 'template<class charT> void g(charT)' declared here,
later in the translation unit

Liviu

Reply via email to