Topic: [Q]: Inaccessible type


Author: shankar@chromatic.com (Shankar Unni)
Date: 1996/08/28
Raw View

John Hancock (jhancock+@IUS5.IUS.cs.cmu.edu) wrote:

> I'm using the CC compiler on an SGI with Irix 5.3.
> I've got code that I thought would be legal, but
> the compiler is complaining.

The example is legal; the compiler has a bug. That version had a hard time
telling whether a use of a protected/private type was legal or not, so it
would unconditionally put out a warning (cfront has the same problem, but
errs on the opposite side: it never puts out a diagnostic, even if the use
is illegal).

You can just ignore the warning (or even shut it off with -woff 3577, but
then you have the same problem as with cfront).


--
Shankar Unni                                  shankar@chromatic.com
Chromatic Research                            (408) 752-9488


[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]





Author: John Hancock <jhancock+@IUS5.IUS.cs.cmu.edu>
Date: 1996/08/22
Raw View
Hi folks --

I'm using the CC compiler on an SGI with Irix 5.3.
I've got code that I thought would be legal, but
the compiler is complaining.

I've got a protected nested class which a friend class
is accessing. Here's the sample code:


----Header Files -----

class Foo{
protected:
  class FooValue{
 .....
 };
FooValue *val;

friend Bar;
};



class Bar{
private:
 Foo::FooValue* readFooValue() const;
....

};

----Source file -----
Foo::FooValue* Bar::readFooValue() const
{
....
}

---------------------

The complaint I get is:

warning(3577): class "Foo::FooValue" is an
inaccessible type (allowed for cfront compatibility)
Foo::FooValue* Bar::readFooValue() const

Now Bar doesn't have a problem accessing FooValue
from WITHIN one of it's own functions -- there's
no complaints there, but the fact that Bar::readFooValue
returns a FooValue* from a private function seems to
bother the compiler. So is this legal or am I really
doing something wrong here?

If this is illegal, why? After all, since the
function is private, Bar isn't giving other
classes access to a FooValue.

(let's ignore the question of WHY I might want to
do something like this...)

Thanks for any info,

John


--
--------------------------------------------------------------------------
     John A. Hancock, Robotics Institute, Carnegie Mellon University
        jhancock@ri.cmu.edu, http://www.ius.cs.cmu.edu/~jhancock/
"Life is short, but long enough to get what's coming to you." - John Alton
---
[ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
[ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
[ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
[ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
[ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]