Some more on the 4.0.1 prerelease (gcc-4.0-20050507). While trying to reproduce a problem with the -Wunreachable-code I stumbled of this. Using the compiler Switches -O2 -O3 give the wrong Line number (25) of the unused code and also repeats the error message 14 times. Using -Os gives the right line number (29) and only one error message. BTW not using optimization doesn't give a warning message while there may be should be one. [EMAIL PROTECTED] test]$ gcc -Wunreachable-code testcase_not_executed.c [EMAIL PROTECTED] test]$
[EMAIL PROTECTED] test]$ gcc -Os -Wunreachable-code testcase_not_executed.c testcase_not_executed.c: In Funktion ปmainซ: testcase_not_executed.c:29: Warnung: wird niemals ausgefhrt [EMAIL PROTECTED] test]$ [EMAIL PROTECTED] test]$ gcc -O2 -Wunreachable-code testcase_not_executed.c testcase_not_executed.c: In Funktion ปmainซ: testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:25: Warnung: wird niemals ausgefhrt testcase_not_executed.c:29: Warnung: wird niemals ausgefhrt [EMAIL PROTECTED] test]$ Here's the c source for this: // reduced Testcase "code never gets executed" // compiled with gcc -Wunreachable-code -O3 // Filename: testcase_not_executed.c // Alexander J. Herrmann 16.05.2005 [EMAIL PROTECTED] #include <stdlib.h> #include <stdio.h> #include <string.h> typedef int bool; static char *aie_banner_head_refresh(void); int main(void) { char *sptr = aie_banner_head_refresh(); printf("%s\n", sptr); return(0); } static char *aie_banner_head_refresh(void) { static char adKategorie[10]; char *isAdKategorie = NULL; memset(adKategorie, '!', sizeof(adKategorie)); *(adKategorie + sizeof(adKategorie)-1) = '\0'; // so nobody can complain if (isAdKategorie != NULL) { strncpy(adKategorie, isAdKategorie, sizeof(adKategorie)-1); } return(adKategorie); } -- Summary: -Wunreachable-code wrong line number and multiple warnings for the same line Product: gcc Version: 4.0.1 Status: UNCONFIRMED Severity: normal Priority: P2 Component: tree-optimization AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: alexander_herrmann at yahoo dot com dot au CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux GCC host triplet: i686-pc-linux GCC target triplet: i686-pc-linux http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21605