This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH 00/89] Compile-time gimple-checking
- From: Michael Matz <matz at suse dot de>
- To: Richard Biener <richard dot guenther at gmail dot com>
- Cc: Andrew MacLeod <amacleod at redhat dot com>, David Malcolm <dmalcolm at redhat dot com>, GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Mon, 28 Apr 2014 14:55:40 +0200 (CEST)
- Subject: Re: [PATCH 00/89] Compile-time gimple-checking
- Authentication-results: sourceware.org; auth=none
- References: <1398099480-49147-1-git-send-email-dmalcolm at redhat dot com> <alpine dot LNX dot 2 dot 00 dot 1404231636530 dot 20425 at wotan dot suse dot de> <53590DBB dot 80104 at redhat dot com> <alpine dot LNX dot 2 dot 00 dot 1404241645220 dot 20425 at wotan dot suse dot de> <CAFiYyc2udUTeO-g3OBG95QpmFnzYxs3sS1_udiT_F7c025O9FQ at mail dot gmail dot com>
Hi,
On Fri, 25 Apr 2014, Richard Biener wrote:
> Btw, I agree we should stick to one style throughout the code-base.
> The advantage of the cast variant is that it can be made work with
> NULL pointers (in the dyn_cast <> case).
NULL pointers shouldn't even be casted at all, there should be sensible
early-outs or conditions to avoid work on NULL.
> Oh, and you could avoid all the base-class changing stuff if you'd
> do the method like
>
> class Foo
> {
> template <class T> T *as () { return as_a <T> (this); }
> }
>
> Best (or worst) of both worlds.
>
> gimple_cond c = g->as<gimple_cond> ();
>
> ;) (you can even put those methods in a separate feature class you
> can simply inherit from)
Yeah, well, I can write ugly C++ as well, it's just that I don't want to
:-/
Ciao,
Michael.