This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug c++/31246] Strange -Wunreachable-code warning with _GLIBCXX_DEBUG



------- Comment #11 from pinskia at gcc dot gnu dot org  2007-03-19 22:31 -------
(In reply to comment #10)
> 
> I fully agree.

I am not agreeing fully,  This warning is only because we can prove something
is pure/const/cannot throw and that only comes because of simple optimization. 
What about this case:

int f(int a) { return a;}

int g(int b)
{
  try
  {
   return f(b);
  }catch (...) { return 0; }
}

Should we warn about the catch being unreachable?
This is the same issue as -Wuninitialized warning in that we warn about a lot
of cases where we should not.  I think this is why this option is not turned on
via either -W or -Wall, it is hard sometimes to work around.

Take even more extrem example where templates come into play:


int f(int a) { return a;}
int f(float a);

template <typename a>
int g(a b)
{
  try
  {
   return f(a);
  }catch (...) { return 0; }
}

int d = g<int>(10);

Should we warn that the catch case is unreachable, I think so as it is obvious
but how do we avoid it, well you can specialize the template but that could get
messy.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=31246


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]