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]
Other format: [Raw text]

[Bug c++/41050] Placement new not seeing base class protected functions



------- Comment #4 from redi at gcc dot gnu dot org  2009-08-13 10:59 -------
(In reply to comment #2)
> Well, if the call is on foo then surely a foo can call; its own methods,

Yes, a foo can call its own methods, but a bar can only call them through a bar
object, not on an object with static type foo.  i.e. bar only has access to the
protected members of a foo that is a sub-object of a bar, and not otherwise.

> whereas if the call is on bar then a bar should see the protected methods of
> its base class foo. Either way it should be visible.

The call is not on a bar, it's on a foo.

Consider:

class foo
{
protected:
    int i;
};

class bar : public foo
{
public:
    void f()
    {
        this->i;                     // OK
        foo().i;                     // protected
        static_cast<foo*>(this)->i;  // protected
    }
};

This is the same situation as your testcase, bar is trying to access protected
members of a foo without going through a bar.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41050


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