public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/21605] New: -Wunreachable-code wrong line number and multiple warnings for the same line
@ 2005-05-16 11:37 alexander_herrmann at yahoo dot com dot au
2005-05-16 11:50 ` [Bug tree-optimization/21605] " pinskia at gcc dot gnu dot org
0 siblings, 1 reply; 2+ messages in thread
From: alexander_herrmann at yahoo dot com dot au @ 2005-05-16 11:37 UTC (permalink / raw)
To: gcc-bugs
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.
[alex@aiengine test]$ gcc -Wunreachable-code testcase_not_executed.c
[alex@aiengine test]$
[alex@aiengine 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
[alex@aiengine test]$
[alex@aiengine 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
[alex@aiengine 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 webmaster@aiengine.org
#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
^ permalink raw reply [flat|nested] 2+ messages in thread
* [Bug tree-optimization/21605] -Wunreachable-code wrong line number and multiple warnings for the same line
2005-05-16 11:37 [Bug tree-optimization/21605] New: -Wunreachable-code wrong line number and multiple warnings for the same line alexander_herrmann at yahoo dot com dot au
@ 2005-05-16 11:50 ` pinskia at gcc dot gnu dot org
0 siblings, 0 replies; 2+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-05-16 11:50 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2005-05-16 11:50 -------
This is a bug in glibc's headers which inlines memset.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21605
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2005-05-16 11:50 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-05-16 11:37 [Bug tree-optimization/21605] New: -Wunreachable-code wrong line number and multiple warnings for the same line alexander_herrmann at yahoo dot com dot au
2005-05-16 11:50 ` [Bug tree-optimization/21605] " pinskia at gcc dot gnu dot org
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).