public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "qrczak at knm dot org dot pl" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/23657] New: Wrong code generated: too much optimized out Date: Wed, 31 Aug 2005 16:05:00 -0000 [thread overview] Message-ID: <20050831160521.23657.qrczak@knm.org.pl> (raw) /* The result should be 7. When compiled with gcc version 4.1.0 20050815 (experimental) with some patches from PLD (incl. PR7776, PR20297, PR23128, PR22533, PR23386) with -O, the result is 0. */ #include <stdio.h> int arr[100]; int *alloc(void) {return arr;} void fill(int n) { int *result = alloc(); int *dest = result; for(;;) { int *next; dest[0] = 7; if (--n == 0) break; next = dest + 1; dest = next; } } int main(void) { fill(5); printf("%d\n", arr[1]); return 0; } /* Looking at the generated assembly code, the whole loop is optimized out, except for filling the first element. Using less temporaries or inlining alloc() makes the bug disappear. The bug manifests only with optimization turned on. */ -- Summary: Wrong code generated: too much optimized out Product: gcc Version: 4.1.0 Status: UNCONFIRMED Severity: normal Priority: P2 Component: c AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: qrczak at knm dot org dot pl CC: gcc-bugs at gcc dot gnu dot org GCC build triplet: i686-pc-linux-gnu GCC host triplet: i686-pc-linux-gnu GCC target triplet: i686-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=23657
next reply other threads:[~2005-08-31 16:05 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top 2005-08-31 16:05 qrczak at knm dot org dot pl [this message] 2005-08-31 16:23 ` [Bug tree-optimization/23657] [4.1 Regression] " pinskia at gcc dot gnu dot org 2005-08-31 22:14 ` qrczak at knm dot org dot pl 2005-08-31 22:23 ` pinskia at gcc dot gnu dot org 2005-08-31 22:23 ` qrczak at knm dot org dot pl
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=20050831160521.23657.qrczak@knm.org.pl \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@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).