public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: "William M. Brack" <wbrack@mmm.com.hk> To: nobody@gcc.gnu.org Cc: gcc-prs@gcc.gnu.org Subject: Re: optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code Date: Fri, 22 Jun 2001 19:56:00 -0000 [thread overview] Message-ID: <20010623025605.10340.qmail@sourceware.cygnus.com> (raw) The following reply was made to PR optimization/3387; it has been noted by GNATS. From: "William M. Brack" <wbrack@mmm.com.hk> To: <gcc-gnats@gcc.gnu.org> Cc: Subject: Re: optimization/3387: GCC 3.0 optimisation -O2 -fPIC produces incorrect code Date: Sat, 23 Jun 2001 10:50:59 +0800 This is a multi-part message in MIME format. ------=_NextPart_000_0046_01C0FBD2.637B41E0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Looking at the bug database for this report, it appears that the attached file was somehow lost during the web submission. If true, please add it to the PR for me; if false, please ignore this (and excuse my ignorance). W. Brack ------=_NextPart_000_0046_01C0FBD2.637B41E0 Content-Type: application/octet-stream; name="bug1.c" Content-Transfer-Encoding: quoted-printable Content-Disposition: attachment; filename="bug1.c" /*=0D The following program generates incorrect code (judged by reading the = generated=0D assembler source) when compiled with flags -O2 and -fPIC. It seems to = compile=0D correctly with flags -O1 and -fPIC, as well as with flags -O2 only.=0D =0D The critical problem is that the routine "f1" modifies the referenced = param (str),=0D so the restoration of the initial value is required ( "str =3D tmp;" ). = However,=0D the generated code deletes that statement.=0D =0D Please note: This fragment is completely artificial - it is a VERY = reduced excerpt=0D from a reasonably complex program in which the problem caused complete = failure.=0D Any criticism about about "poor coding" will be taken as a personal = insult ;>)=0D */=0D =0D int f1(int uri, char **str);=0D int f2(int uri, char **str);=0D =0D int bug(int uri, char *str) {=0D int ret;=0D char *tmp =3D str; /* Save the initial value of param str */=0D =0D ret =3D f1(uri, &str); /* This routine modifies the value of str = */=0D if (ret !=3D 0) {=0D str =3D tmp; /* Restore the initial value of str */=0D ret =3D f2(uri, &str);=0D }=0D if (ret !=3D 0)=0D return(ret);=0D =0D ret =3D f2(uri, &str);=0D =0D return(0);=0D }=0D ------=_NextPart_000_0046_01C0FBD2.637B41E0--
next reply other threads:[~2001-06-22 19:56 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2001-06-22 19:56 William M. Brack [this message] -- strict thread matches above, loose matches on Subject: below -- 2001-09-12 14:24 sirl 2001-09-09 10:44 sirl 2001-06-22 17:56 wbrack
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=20010623025605.10340.qmail@sourceware.cygnus.com \ --to=wbrack@mmm.com.hk \ --cc=gcc-prs@gcc.gnu.org \ --cc=nobody@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).