[cfe-dev] -Wunreachable-code and templates
David Blaikie
dblaikie at gmail.com
Wed Nov 30 18:33:39 PST 2011
On Wed, Nov 30, 2011 at 1:26 PM, Ted Kremenek <kremenek at apple.com> wrote:
> On Nov 30, 2011, at 11:54 AM, Ted Kremenek wrote:
>
> > Realistically, unless we really want to be super clever here, the most
> > immediate solution to making -Wunreachable-code useful in the presence of
> > templates is to simply have it skip templates entirely.
>
> In the spirit of improving the utility of the warning, I have gone and done
> this in r145520. If we come up with a better solution, we can certainly
> change this. I believe the general solution, if one exists, will be very
> complex.
Thanks Ted - I tend to agree once we got to those examples of
conditionally unreachable code that it appears to be a hard problem. I
did check gcc's behavior, but it seems they gave up on this warning
entirely around 4.3-4.4 (because their implementation was based on
their optimizations & fraught with many more problems than just
templates, by the sounds of it) so we're not missing any GCC parity
here by not checking templates.
Slightly related/minor tidyup - should the isType/ValueDependent
checks in tryEvaluate/tryEvaluateBool be removed (and possibly
replaced with assertions) as they don't seem to do anything - we
weren't visiting dependent contexts previously nor are we now.
- David
More information about the cfe-dev
mailing list