This is the mail archive of the gcc@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]

c++ overloading operator question


hi folks.

The following code fails to compile with g++:

class foobar
{
public:
  struct hotdog;
  hotdog * p;
  operator hotdog *();
};

foobar::operator hotdog * ()	<-- parse error before '*'
{
  return p;
}

apparently the c++ front end is evaluating hotdog in the scope outside
of "class foobar".  It should be evaluated inside the foobar scope.

cp/parse.y has this:

        /* Names here should be looked up in class scope ALSO.  */
        | operator type_specifier_seq conversion_declarator
                { $$ = grokoptypename ($2.t, $3); }

so at least somebody knew what was _supposed_ to happen.

Are there any g++ experts out there that know what needs to be hacked
on to have this work-- or is support for this already there, but not
working ?!

Thanks.
Aldy

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