public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: norman@arcady.u-net.com To: gcc-gnats@gcc.gnu.org Subject: c/4161: gcc c compiler producing incorrect code Date: Tue, 28 Aug 2001 16:36:00 -0000 [thread overview] Message-ID: <200108282328.AAA13836@arcady.u-net.com> (raw) >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:
reply other threads:[~2001-08-28 16:36 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=200108282328.AAA13836@arcady.u-net.com \ --to=norman@arcady.u-net.com \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).