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

Reply via email to