This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C++ PATCH: throw (T *)NULL and dynamic_cast
- To: nathan at cs dot bris dot ac dot uk
- Subject: Re: C++ PATCH: throw (T *)NULL and dynamic_cast
- From: Jason Merrill <jason at cygnus dot com>
- Date: 16 Sep 1999 13:03:17 -0700
- Cc: gcc-patches at gcc dot gnu dot org
- References: <3766CEEF.E9C2104@unet.univie.ac.at> <3768CC61.F8E35DA@acm.org> <37693D6C.FF620D04@acm.org> <u9vha5l9ag.fsf@yorick.cygnus.com> <37C2BBDC.45B41092@acm.org> <u97lmlkl8e.fsf@yorick.cygnus.com> <37C4F186.2D14A324@acm.org> <u9hflndklm.fsf@yorick.cygnus.com> <37CD302F.5DB11371@acm.org> <u9pv021cdx.fsf@yorick.cygnus.com> <37E0C21D.8576C88D@acm.org>
Looks good, thanks! A couple of bugs I see:
You should use binfo_from_vbase, rather than TREE_VIA_VIRTUAL; the latter
only checks the most immediate derivation.
Declaring op== inline in tinfo.cc is invalid; the standard says an inline
function must be declared inline and defined in all translation units where
it's used. Instead, you could use a static helper function in tinfo.cc, or
just leave it alone.
And some style nits:
The comment for upcast refers to *RESULT; I think you mean *ADJPTR.
Please describe in your function comments what meaning (and form, if not
obvious) the parameters have, not just whether or not they can be null.
And please do describe the parms and return value of the do_* functions.
s/heirarchy/hierarchy/
s/derrived/derived/
Please use something like
const type_info *const nonvirtual_base_type
= (static_cast <const type_info *> (0) + 1);
rather than write (const void *)1 explicitly.
Please use inlines to test access paths; something like
return contained_nonpublic_p (access_path);
is more readable than
return (access_path & contained_public) == contained_mask;
Your comment at the end of class::do_dyncast,
+ // We found SUBOBJ as a private non-virtual base, therefore all
+ // cross casts will fail. We would have already found a down cast,
+ // should there have been one.
seems to imply that the down cast has also failed at this point, which I
don't think is true. I'd suggest
We have already found a down cast, if
// there is one.
instead.
Jason