Bug#196600: gcc -Wunreachable-code gives false complaints
Package: gcc-3.3
Version: 3.3-2
Gcc complains that a declaration "will never be executed" for a
code path that executes, as shown below.
If I:
. remove the exit line
. change "int ix;" to "int ix = 0;"
or
. move the declaration to line 2 or after line 3
the complaint go away.
$ cat -n test.c
#include <stdio.h>
int main(int argc, char *argv[]) { /* line 3 */
if (argc != 1) exit(1);
{
int ix; /* line 7 */
ix = printf("hello\n");
printf("%d\n", ix);
}
return 0;
}
$ gcc-2.95 -Wunreachable-code test.c
cc1: Invalid option `-Wunreachable-code'
$ gcc-3.0 -Wunreachable-code test.c; ./a.out
hello
6
$ gcc-3.2 -Wunreachable-code test.c; ./a.out
test.c: In function `main':
test.c:7: warning: will never be executed
hello
6
$ gcc-3.3 -Wunreachable-code test.c; ./a.out
test.c: In function `main':
test.c:7: warning: will never be executed
hello
6
$ dpkg -l gcc-\?.\? | grep ^i
ii gcc-3.0 3.0.4-7 The GNU C compiler.
ii gcc-3.2 3.2.3-0pre9 The GNU C compiler
ii gcc-3.3 3.3-2 The GNU C compiler
$
Regards,
/Karl
-----------------------------------------------------------------------
Karl Hammar Aspö Data karl@kalle.csb.ki.se
Lilla Aspö 2340 Networks
S-742 94 Östhammar +46 173 140 57 Computers
Sweden +46 70 511 97 84 Consulting
-----------------------------------------------------------------------
Reply to: