Namespace handling bug in GCC 3.1?

Lassi A. Tuura lassi.tuura@cern.ch
Wed Aug 7 09:55:00 GMT 2002


By my reading all of the below are legitimate C++.  Is this a
bug in GCC 3.1 handling of using-declarations at function scope?

$ /usr/local/cluster/gcc-3.1/objdir/bin/c++ -v    
Reading specs from /usr/local/cluster/gcc-3.1/objdir/bin/../lib/gcc-lib/i686-pc-linux-gnu/3.1/specs
Configured with: ../configure --prefix=/usr/local/cluster/gcc-3.1/objdir/
Thread model: single
gcc version 3.1

$ /usr/local/cluster/gcc-3.1/objdir/bin/c++ -c foobar.cc
$ /usr/local/cluster/gcc-3.1/objdir/bin/c++ -c bar.cc
$ /usr/local/cluster/gcc-3.1/objdir/bin/c++ -c foo.cc
foo.cc: In function `void f()':
foo.cc:3: parse error before `operator'
foo.cc:3: `I' undeclared (first use this function)
foo.cc:3: (Each undeclared identifier is reported only once for each function 
   it appears in.)
foo.cc:3: `i' undeclared (first use this function)

$ cat foo.cc
#include <utility>
struct I { bool operator== (const I &) const; };
void f () { using std::rel_ops::operator!=; I i; i != i; }
$ cat bar.cc
#include <utility>
struct I { bool operator== (const I &) const; };
void f () { using namespace std::rel_ops; I i; i != i; }
$ cat foobar.cc 
#include <utility>
struct I { bool operator== (const I &) const; };
using std::rel_ops::operator!=;
void f () { I i; i != i; }

Thanks for the good work!
//lat
-- 
I am ready to meet my Maker.  Whether my Maker is prepared for the
great ordeal of meeting me is another matter.  --Winston Churchill



More information about the Gcc mailing list