$ /scratch/zack/i/gcc-vanilla/bin/g++ -v Using built-in specs. Configured with: /home/zack/src/gcc/HEAD/vanilla/configure --prefix=/scratch/zack/i/gcc-vanilla --disable-checking --enable-languages=c,c++ --disable-multilib Thread model: posix gcc version 4.0.0 20050122 (experimental) $ /scratch/zack/i/gcc-vanilla/bin/g++ -S -O2 -W -Wall testcase.cc testcase.cc: In function ‘void finalize()’: testcase.cc:29: warning: control may reach end of non-void function ‘bool N::operator!=(N) const’ being inlined I will attach the testcase.
Created attachment 8039 [details] test case
Created attachment 8040 [details] shorter test case
Here is the simplified testcase: static inline bool f() throw() { return 0; } bool ff() { return f(); }
I think the problem is that we don't look passed eh_spec_block trees.
The problem is not related eh_spec_block as we are gimple at this point.
The problem is that block_may_fallthru does not handle try_catch_expr and eh_filter_expr.
Mine. I am testing a patch right now.
(In reply to comment #7) > Mine. I am testing a patch right now. Hmm, I get a bootstrap failure with the patch: /Users/pinskia/src/local3/gcc/libstdc++-v3/libsupc++/eh_alloc.cc: In function 'void __cxxabiv1:: __cxa_free_exception(void*)': /Users/pinskia/src/local3/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:157: error: Fallthru to exit from bb 12 /Users/pinskia/src/local3/gcc/libstdc++-v3/libsupc++/eh_alloc.cc:157: internal compiler error: verify_flow_info failed
(In reply to comment #8) > (In reply to comment #7) > > Mine. I am testing a patch right now. > > Hmm, I get a bootstrap failure with the patch: And here is the reduced testcase for that failure: void f(void); void g(void) throw() { f(); } I have to rethink this, maybe we should skip those trees before passing to block_may_fallthru.
(In reply to comment #9) > I have to rethink this, maybe we should skip those trees before passing to block_may_fallthru. Yes that fixes it (I will submit the patch after lunch).
All this code will go away for 4.1 anyways which is good (and we will not have false postives any more). Anyways patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01675.html>.
*** Bug 19573 has been marked as a duplicate of this bug. ***
with the following the problem also does occur ---------- O3Wall.cc ------- #include <cmath> double test( double x ) { return fabs(x); } ---------- O3Wall.cc ------- > g++-4.0-20050123 O3Wall.cc -O3 -Wall -c O3Wall.cc: In function 'double test(double)': O3Wall.cc:4: warning: control may reach end of non-void function 'double fabs(double)' being inlined > g++-4.0-20050123 -v Using built-in specs. Configured with: ../gcc-4.0-20050123/configure --prefix=/opt/gcc-4.0-20050123 --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-nls --program-suffix=-4.0-20050123 --disable-checking --with-arch=pentium3 Thread model: posix gcc version 4.0.0 20050123 (experimental)
oh sorry, i did not read the bug history :-( regards andre
*** Bug 19631 has been marked as a duplicate of this bug. ***
(In reply to comment #11) > Anyways patch here: <http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01675.html>. the patch (used with gcc-4.0-20050123) doesn't fix the following code ---------- O3Wall-2.cc ------- #include <stack> int main() { int x = 3; int* ptr = &x; std::stack<int*> s; s.push(ptr); s.pop(); return 0; } ---------- O3Wall-2.cc ------- > g++-4.0-20050123-1 -O3 -Wall O3Wall-2.cc /opt/gcc-4.0-20050123-1/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../include/c++/4.0.0/bits/stl_deque.h: In destructor 'std::_Deque_base<_Tp, _Alloc>::~_Deque_base() [with _Tp = int*, _Alloc = std::allocator<int*>]': /opt/gcc-4.0-20050123-1/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../include/c++/4.0.0/bits/stl_deque.h:411: warning: control may reach end of non-void function 'typename _Alloc::rebind<_Tp*>::other std::_Deque_base<_Tp, _Alloc>::_M_get_map_allocator() const [with _Tp = int*, _Alloc = std::allocator<int*>]' being inlined /opt/gcc-4.0-20050123-1/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../include/c++/4.0.0/bits/deque.tcc: In member function 'void std::deque<_Tp, _Alloc>::_M_reallocate_map(size_t, bool) [with _Tp = int*, _Alloc = std::allocator<int*>]': /opt/gcc-4.0-20050123-1/lib/gcc/i686-pc-linux-gnu/4.0.0/../../../../include/c++/4.0.0/bits/deque.tcc:750: warning: control may reach end of non-void function '_Tp** std::_Deque_base<_Tp, _Alloc>::_M_allocate_map(size_t) [with _Tp = int*, _Alloc = std::allocator<int*>]' being inlined > g++-4.0-20050123-1 -v Using built-in specs. Configured with: ../gcc-4.0-20050123/configure --prefix=/opt/gcc-4.0-20050123-1 --enable-shared --enable-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --disable-nls --program-suffix=-4.0-20050123-1 --disable-checking --with-arch=pentium3 Thread model: posix gcc version 4.0.0 20050123 (experimental)
Another patch here: http://gcc.gnu.org/ml/gcc-patches/2005-01/msg01964.html
Subject: Bug 19583 CVSROOT: /cvs/gcc Module name: gcc Changes by: ian@gcc.gnu.org 2005-01-27 14:36:22 Modified files: gcc : ChangeLog gimple-low.c tree-inline.c Log message: PR middle-end/19583 * gimple-low.c (try_catch_may_fallthru): New static function. (block_may_fallthru): Handle TRY_CATCH_EXPR. * tree-inline.c (expand_call_inline): Don't warn about reaching the end of a non-void function being inlined if the function uses a return slot. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7305&r2=2.7306 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimple-low.c.diff?cvsroot=gcc&r1=2.19&r2=2.20 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/tree-inline.c.diff?cvsroot=gcc&r1=1.169&r2=1.170
Fixed.
Created attachment 8085 [details] preprocessed testcase which still gives wrong warnings
Subject: Bug 19583 CVSROOT: /cvs/gcc Module name: gcc Changes by: ian@gcc.gnu.org 2005-01-28 17:32:58 Modified files: gcc : ChangeLog gimple-low.c Log message: PR middle-end/16558 PR middle-end/19583 * gimple-low.c (block_may_fallthru): TRY_FINALLY_EXPR only falls through if both operands fall through. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7319&r2=2.7320 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimple-low.c.diff?cvsroot=gcc&r1=2.20&r2=2.21
Created attachment 8101 [details] Preprocessed sources showing the problem With this preprocessed sources I see the same problem when compiling with g++ -W -Wall -O -fno-exceptions -c -o test2.o test2.ii Removing either (or both) of -O or -fno-exceptions supresses the warnings.
This does not seem to be fixed so reopening.
(In reply to comment #23) > This does not seem to be fixed so reopening. I opened another PR because it is related but not fully the same problem. (PR 19699).
(In reply to comment #24) > (In reply to comment #23) > > This does not seem to be fixed so reopening. > I opened another PR because it is related but not fully the same problem. (PR 19699). We still (as of CVS from Feb 8) get the warning if the throw-specifier is not empty. This example still gives the warning with -Wall -O1: struct E{}; inline int bar() throw(E) { return 0; } void foo () { bar(); }
New patch: http://gcc.gnu.org/ml/gcc-patches/2005-02/msg00342.html
Subject: Bug 19583 CVSROOT: /cvs/gcc Module name: gcc Changes by: ian@gcc.gnu.org 2005-02-09 21:40:01 Modified files: gcc : ChangeLog gimple-low.c Log message: PR middle-end/19583 * gimple-low.c (try_catch_may_fallthru): In EH_FILTER_EXPR case, just check whether EH_FILTER_FAILURE falls through. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.7424&r2=2.7425 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/gimple-low.c.diff?cvsroot=gcc&r1=2.21&r2=2.22
Subject: Bug 19583 CVSROOT: /cvs/gcc Module name: gcc Changes by: ian@gcc.gnu.org 2005-02-09 21:40:36 Modified files: gcc/testsuite : ChangeLog Added files: gcc/testsuite/g++.dg/warn: Wreturn-type-3.C Log message: PR middle-end/19583 * g++.dg/warn/Wreturn-type-3.C: New test. Patches: http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5008&r2=1.5009 http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/warn/Wreturn-type-3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1