This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/41050] Placement new not seeing base class protected functions
- From: "redi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 13 Aug 2009 10:59:30 -0000
- Subject: [Bug c++/41050] Placement new not seeing base class protected functions
- References: <bug-41050-6594@http.gcc.gnu.org/bugzilla/>
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
------- 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