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++/46476] Missing Warning about unreachable code after return


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=46476

--- Comment #16 from David Binderman <dcb314 at hotmail dot com> ---
(In reply to Manuel López-Ibáñez from comment #14)
> But the main barrier for this is not technical or acceptance, it is 
> leadership and human resources. 

And the usual time and money. There are plenty of static analysers out there.
Unless it is substantially better, why write another one ?

My favourite static analyser, cppcheck, says this for the original code:

$ ~/cppcheck/trunk/cppcheck --enable=all bug46476.cc
[bug46476.cc:5]: (style) Statements following return, break, continue, goto or
throw will never be executed.
[bug46476.cc:11]: (style) Statements following return, break, continue, goto or
throw will never be executed.
[bug46476.cc:8]: (style) The function 'bar' is never used.
[bug46476.cc:2]: (style) The function 'foo' is never used.
$

which pretty much does the job.

Running the same static analyser over the source code of a recent gcc
found 22 occurrences of this kind of problem.

Here they are:

$ fgrep "Statements following" cppcheck.20170617.out
[trunk/gcc/c/c-decl.c:3211]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/gcc/fortran/arith.c:2009]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/dwarf.c:2709]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/dwarf.c:2758]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/dwarf.c:2892]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/dwarf.c:3025]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/elf.c:448]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/elf.c:493]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/elf.c:967]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/fileline.c:64]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/fileline.c:75]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/pecoff.c:499]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/pecoff.c:564]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libbacktrace/pecoff.c:931]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libcilkrts/runtime/cilk_fiber.cpp:968]: (style) Statements following
return, break, continue, goto or throw will never be executed.
[trunk/libcilkrts/runtime/scheduler.c:2468]: (style) Statements following
return, break, continue, goto or throw will never be executed.
[trunk/libcilkrts/runtime/scheduler.c:2550]: (style) Statements following
return, break, continue, goto or throw will never be executed.
[trunk/libcilkrts/runtime/scheduler.c:2439]: (style) Statements following
return, break, continue, goto or throw will never be executed.
[trunk/libffi/src/dlmalloc.c:3877]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libgomp/error.c:90]: (style) Statements following return, break,
continue, goto or throw will never be executed.
[trunk/libgomp/libgomp-plugin.c:79]: (style) Statements following return,
break, continue, goto or throw will never be executed.
[trunk/libobjc/error.c:41]: (style) Statements following return, break,
continue, goto or throw will never be executed.
$

Most of them seem to be in libbacktrace. I could look deeper into these
and generate some bug reports. That's the usual way to provoke gcc developers
into developing a new warning: show that the gcc source code would benefit
from it.

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