public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* c/4161: gcc c compiler producing incorrect code
@ 2001-08-28 16:36 norman
0 siblings, 0 replies; only message in thread
From: norman @ 2001-08-28 16:36 UTC (permalink / raw)
To: gcc-gnats
>Number: 4161
>Category: c
>Synopsis: c compiler produces incorrect code
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: wrong-code
>Submitter-Id: net
>Arrival-Date: Tue Aug 28 16:36:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator: Norman Stevens
>Release: 3.0.1
>Organization:
>Environment:
System: Linux arcady 2.2.16-1 #5 Mon Jun 12 19:43:48 BST 2000 i586 unknown
Architecture: i586
host: i386-pc-linux-gnu
build: i386-pc-linux-gnu
target: i386-pc-linux-gnu
configured with: ../gcc-3.0.1/configure --prefix=/usr i386-pc-linux-gnu : (reconfigured)
>Description:
The code generated from the following source is incorrect. The line
"str = tmp;" seems to be removed by the optimizer. If the code is
compiled using -O0, -O1 or -O2 then the output is correct, if the code
is compiled with -O2 then the output is incorrect. Note that the
problem only occurs when the -fPIC and -O2 options are _both_ present.
With -O2 the output is
dtd/kdex.dtd
/kdex.dtd
without -O2 the output (correct) is
dtd/kdex.dtd
dtd/kdex.dtd
>How-To-Repeat:
gcc -fPIC -O2 -o u u.c
/*********************************************************/
# 1 "u.c"
extern int printf (const char *, ...);
void xmlCleanURI(void *p)
{
}
static int xmlParseRelativeURI(void *p, const char **str)
{
printf ( "%s\n", *str);
return 0;
}
static int xmlParseAbsoluteURI(void *p, const char **str)
{
printf ( "%s\n", *str);
while (**str != '/' && **str != '\0') (*str)++;
return 2;
}
int
xmlParseURIReference(void * uri, const char *str)
{
int ret;
const char *tmp = str;
ret = xmlParseAbsoluteURI(uri, &str);
if (ret != 0)
{
xmlCleanURI(uri);
str = tmp;
ret = xmlParseRelativeURI(uri, &str);
}
return ret;
}
int main (void)
{
xmlParseURIReference (0, "dtd/kdex.dtd");
return 0;
}
/*********************************************************/
>Fix:
Removing the -O2 flag is a workaround.
>Release-Note:
>Audit-Trail:
>Unformatted:
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2001-08-28 16:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-28 16:36 c/4161: gcc c compiler producing incorrect code norman
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).