[Bug c++/64077] dynamic_cast incorrectly rejected for private base

gcc at dixie dot net.nz gcc-bugzilla@gcc.gnu.org
Thu Nov 27 20:15:00 GMT 2014


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=64077

Andrew Dixie <gcc at dixie dot net.nz> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #4 from Andrew Dixie <gcc at dixie dot net.nz> ---
(In reply to Daniel Krügler from comment #3)

Given the reference to core issue 665, I now think the wording and intent of
the standard is clear.

For completeness I've given an example below, but I'm happy this can be closed.

Thanks.


class base { virtual ~base() {} };
class derived : private base {
        friend bool t1(derived *);
};

bool t1(derived *x) {
        return dynamic_cast<base *>(x) != 0;
}

If the 'accessible' in p5 includes friendships relationships, then the
dynamic_cast should succeed.
If the 'accessible' in p5 requires a public base (like is required by p8), then
the dynamic cast should fail (or be ill-formed).
I think the wording of the standard clearly specifies succeed.


More information about the Gcc-bugs mailing list