[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#319309: g++-4.0 regression



Package: g++
Version: 4.0.0-2
Severity: normal

Hi, I've found a regression in g++-4.0 when optimization is turned on.
Compile the attached example source code with:

	g++ -Wall -O3 -c bug.cc

g++ produces the warning:

bug.cc:9: warning: control may reach end of non-void function 'char* f(char*)' being inlined

This is wrong, as should be obvious, since every possible control path
in f() either leads to a return or a throw.  g++ 3.x correctly
analyses the code and does not generate a warning.

The attached file is almost minimal; it seems to depend on the
specific if condition in f() and the fact that pointers are being
used. I haven't found a way to further simplify the case without
making the error go away.

This particular case happens only with -O3, but I've also found
another case that happens with -O1 (same warning message). It's
embedded in some rather involved code, so I'll forward it to this bug
later after I reduce it to a minimal test case.


T

-- 
I'm still trying to find a pun for "punishment"...
char *f(char *cp) {
  if (!cp || *cp=='\0') {
    throw "error";
  } else {
    return 0;
  }
}
char *h(char *cp) {
  return f(cp);
}


Reply to: