This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/28444] New: static_cast allowed, even if only the base class is accessible
- From: "tim at klingt dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 20 Jul 2006 11:55:12 -0000
- Subject: [Bug c++/28444] New: static_cast allowed, even if only the base class is accessible
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
hi all,
i searched for a similar bug, but i'm not sure, if it has been reported:
the following code compiles fine with gcc, but it shouldn't:
struct foo
{
friend class caster;
};
struct bar:
protected foo
{
};
struct caster
{
foo * cast(bar* b)
{
return static_cast<foo*>(b);
}
};
int main()
{
bar * b = new bar;
caster c;
foo * f = c.cast(b);
}
from my understanding, it should only compile if, caster would be a friend of
bar
--
Summary: static_cast allowed, even if only the base class is
accessible
Product: gcc
Version: 4.1.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: tim at klingt dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=28444