On 27 October 2014 12:07, Geza Herman <geza@xxxxxxxxxxx> wrote: > Hi, > > Have a look at this simple code: > > template <typename OBJECT> > struct Foo { > static void fn() {foo(OBJECT());} > }; > struct Bar {}; > void foo(int); > // void foo(Bar); > void x() { > Foo<int>::fn(); > // Foo<Bar>::fn(); > } > > With gcc 4.7-5.0, this code doesn't compile with the error "‘foo’ was not > declared in this scope, and no declarations were found by argument-dependent > lookup at the point of instantiation" > > But, if you remove "void foo(int)", and the call of "Foo<int>::fn()", and > activate the two commented lines, this code compiles. > > I don't understand what difference it makes whether I use "int" or "Bar" as > a parameter. > > Interestingly, clang 3.5 behaves the same ("int" version doesn't compile, > but "Bar" version does). gcc 4.6 or older compiles this code. > > Is it a bug? No, it's a bug fix. It's documented at https://gcc.gnu.org/gcc-4.7/changes.html#cxx See also "Name lookup changes" at https://gcc.gnu.org/gcc-4.7/porting_to.html