This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Parse error with scope-resolution operator


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/>



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]