[cfe-dev] -Wunreachable-code and templates

David Blaikie dblaikie at gmail.com
Wed Feb 15 11:19:44 PST 2012


On Wed, Feb 15, 2012 at 11:12 AM, Ted Kremenek <kremenek at apple.com> wrote:
> On Feb 15, 2012, at 10:58 AM, David Blaikie <dblaikie at gmail.com> wrote:
>
> Honestly I think there may end up being an argument for this - and
> using a lesser definition of reachability (the same one MSVC and GCC
> appear to use - purely structural with no constant conditional
> evaluation (eg: "if {return} else {return} return" finds the trailing
> return to be unreachable, but "if {return} return" doesn't, even if
> the condition on the if is reachable)) under some circumstances (yes -
> this would cause more false positives on every other analysis-based
> warning, though I'm curious how much time we spend on CFG construction
> for all those currently - I might try that as a separate experiment if
> I can get usable/stable numbers from reasonable data sets).
>
>
> Hi David,
>
> I honestly didn't understand this paragraph.  Could you elucidate?

Sorry - bit rambly/nested.

GCC and MSVC use a fairly simplistic definition of reachability that
does not consider conditions at all, eg:

if (x)
  return
else
  return
return // unreachable by GCC and MSVC, regardless of 'x'

if (x)
  return
return // reachable by GCC and MSVC, regardless of 'x'

I'd be interested to see how much faster we could build the CFG if we
did it in this way - how much we're paying for a stronger definition
of reachability. I suppose this wouldn't be hard to test - no doubt
there's some code in the CFG builder that evaluates a condition to
determine if it's true, false, or unproven & I could just change that
to always unproven.




More information about the cfe-dev mailing list