A
Alex Vinokur
Hi,
GNU g++ 3.4 detects an error in code below.
What is wrong here?
--------- [C++] foo.cpp : BEGIN ---------
template <typename T>
struct Foo
{
friend bool operator== <T> (const Foo<T>&, const Foo<T>&); // Line#4
};
template <typename T>
bool operator== (const Foo<T>&, const Foo<T>&)
{
return false;
}
int main()
{
Foo<int> foo;
return 0;
}
--------- [C++] foo.cpp : END -----------
------ Compilation with GNU gcc 3.3 (Cygwin) : BEGIN ------
$ g++ --version
g++ (GCC) 3.3.3 (cygwin special)
[---omitted---]
$ g++ foo.cpp
// No errors/warnings
------ Compilation with GNU gcc 3.3 (Cygwin) : END --------
------ Compilation with GNU gcc 3.4 (DJGPP) : BEGIN ------
$ gpp --version
gpp.exe (GCC) 3.4.1
[---omitted---]
$ gpp foo.cpp
foo.cpp:4: error: declaration of `operator==' as non-function
foo.cpp:4: error: expected `;' before '<' token
------ Compilation with GNU gcc 3.4 (DJGPP) : END --------
GNU g++ 3.4 detects an error in code below.
What is wrong here?
--------- [C++] foo.cpp : BEGIN ---------
template <typename T>
struct Foo
{
friend bool operator== <T> (const Foo<T>&, const Foo<T>&); // Line#4
};
template <typename T>
bool operator== (const Foo<T>&, const Foo<T>&)
{
return false;
}
int main()
{
Foo<int> foo;
return 0;
}
--------- [C++] foo.cpp : END -----------
------ Compilation with GNU gcc 3.3 (Cygwin) : BEGIN ------
$ g++ --version
g++ (GCC) 3.3.3 (cygwin special)
[---omitted---]
$ g++ foo.cpp
// No errors/warnings
------ Compilation with GNU gcc 3.3 (Cygwin) : END --------
------ Compilation with GNU gcc 3.4 (DJGPP) : BEGIN ------
$ gpp --version
gpp.exe (GCC) 3.4.1
[---omitted---]
$ gpp foo.cpp
foo.cpp:4: error: declaration of `operator==' as non-function
foo.cpp:4: error: expected `;' before '<' token
------ Compilation with GNU gcc 3.4 (DJGPP) : END --------