Why does GCC not warn for unreachable code?

前端 未结 2 1381
清歌不尽
清歌不尽 2020-12-07 01:01

I wonder why gcc (4.6.3) gives me no warning for the unreachable code in this example:

#include 

int status(void)
{         


        
2条回答
  •  再見小時候
    2020-12-07 01:20

    gcc 4.4 will give you warning. In the later versions of gcc this feature (-Wunreachable-code) has been removed.

    See here: http://gcc.gnu.org/ml/gcc-help/2011-05/msg00360.html

    The -Wunreachable-code has been removed, because it was unstable: it relied on the optimizer, and so different versions of gcc would warn about different code. The compiler still accepts and ignores the command line option so that existing Makefiles are not broken. In some future release the option will be removed entirely.

    Ian

提交回复
热议问题