Parse error with scope-resolution operator
Richard B. Kreckel
kreckel@ginac.de
Mon Jul 10 08:44:00 GMT 2000
Hello,
The following piece of code produces a parse error when run to any GCC
that I have tried so far. AFAICT it should be ok to specify the global
namespace at any place, and other compilers (SGI, Sun) indeed do accept
that code. (A simple workaround is of course to insert spaces).
class foo {
public:
foo() { n = 0; };
foo(int i) { n = i; };
int get() { return n; }
~foo() { };
private:
int n;
};
bool operator<(int l, foo r)
{ return l<r.get(); }
bool operator>(int l, foo r)
{ return l>r.get(); }
int main(void) {
// (1<::foo()) produces parse error, but should be ok, since we are
// living in the global namespace. (1>::foo()) works, however.
if (1<::foo())
return 0;
else
return 1;
}
Regards
-richy.
--
Richard Kreckel
<Richard.Kreckel@Uni-Mainz.DE>
< http://wwwthep.physik.uni-mainz.de/~kreckel/ >
More information about the Gcc-bugs
mailing list