patch:jet another bug in dynamic_cast

Nathan Sidwell
Wed Jun 30 23:15:00 GMT 1999

Alfred Minarik wrote:

> In this case
>    A    A
>    |    |
> B  C1  C2
> \   |   /
>  \  |  private
>   \ | /
>     D1
> I thought a dynamic_cast from B to A should succed
> as it reads
>       Otherwise, if v points (refers) to a public base class sub-object
>       of the most derived object, and the type of the most derived
>       object has an unambiguous public base class of type T, the result
>       is a pointer (an lvalue referring) to the T sub-object of the most
>       derived object.
> for me A (the baseclass of C1) was an unambiguous public base of D1
> as the other A was only private reachable.
> In fact my patch does it that way ...
The standard never explicitly states what the phrase `unambiguous public base'
means, and it does use a variety of different phrases which all seem to mean
the same thing ("unambiguous and accessible base" (4.10/3), or "unambiguous
direct or indirect base ... and is accessible" (10.3/5) `not ... private,
protected or ambiguous' (15.3/3) for instance). It does state that
accessibility is applied after visibility (11/4). Ambiguity is described in
terms of visibility (10.2/2). This implies that `unambiguous public base'
should mean {publicly accessible} {unambiguous base}. I cannot find words to
support the alternative view of searching only the publicly accessible paths.


Dr Nathan Sidwell :: Computer Science Department :: Bristol University
        I have seen the death of PhotoShop -- it is called GIMP

More information about the Gcc-patches mailing list