Gcc bug or not?
Geza Herman
geza@bitquad.com
Mon Oct 27 12:07:00 GMT 2014
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?
Thanks,
Geza
More information about the Gcc-help
mailing list