[cfe-dev] -Wunreachable-code and templates

Ted Kremenek kremenek at apple.com
Wed Nov 30 12:02:49 PST 2011


On Nov 30, 2011, at 11:54 AM, Ted Kremenek wrote:

> My concern, however, is that this approach is still fundamentally flawed.  By analyzing the instantiations, we are still impacted by the control-flow of that particular instantiation.  For example, suppose we have:
> 
> template <typename T> void foo() {
>   {
>     T x;
>   }
>   printf("is this dead?");
> }
> 
> If the instantiated type for 'T' has a 'noreturn' destructor, then the printf() call is unreachable.  If it doesn't, it is reachable.

A simpler example:

template <typename T> void foo() {
  T::bar();
  printf("is this dead?");
}

Same issue as before.  'bar()' could be marked 'noreturn', but it depends on the instantiation.  Thus control-flow could vary significantly between instantiations.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20111130/2e85f07a/attachment.html>


More information about the cfe-dev mailing list