Description of problem: The source code attached to this bug gives the following warning if compiled with gcc -O2 -c -Wp,-D_FORTIFY_SOURCE=2 -Wunreachable-code -o test.o test.c test.c: In function âtestâ: test.c:26: warning: will never be executed I think this is bogus, if the malloc() succeeds the strcpy() in this line will be executed. Dropping -Wp,-D_FORTIFY_SOURCE=2 or -O2 from the compiler command line makes the message go away. Replacing the single strcasecmp in the source with strcmp makes a lot more "will never be executed" warnings pop up. Please note that the source attached is a stripped-down version of a longer piece of code where the operations actually make some kind of sense :) Version-Release number of selected component (if applicable): gcc-4.0.1-13 How reproducible: Always Steps to Reproduce: 1. Compile attached code with command line above 2. 3. Actual results: "will never be executed" warnings Expected results: no warnings Additional info:
Created attachment 118810 [details] Compiler test case
That's not spurious, there is really unreachable code, but that's correct. I'd say _FORTIFY_SOURCE and -Wunreachable-code warning are mutual exclusive choices, similarly to using debugging code etc. See -Wunreachable-code's description in man gcc or info gcc, particularly: This option is not made part of `-Wall' because in a debugging version of a program there is often substantial code which checks correct functioning of the program and is, hopefully, unreachable because the program does work. Another common use of unreachable code is to provide behavior which is selectable at compile-time.