This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/49279] [4.5/4.6/4.7 Regression] Optimization incorrectly presuming constant variable inside loop in g++ 4.5 and 4.6 with -O2 and -O3 for x86_64 targets
- From: "jakub at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 04 Oct 2011 16:57:36 +0000
- Subject: [Bug tree-optimization/49279] [4.5/4.6/4.7 Regression] Optimization incorrectly presuming constant variable inside loop in g++ 4.5 and 4.6 with -O2 and -O3 for x86_64 targets
- Auto-submitted: auto-generated
- References: <bug-49279-4@http.gcc.gnu.org/bugzilla/>
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=49279
--- Comment #6 from Jakub Jelinek <jakub at gcc dot gnu.org> 2011-10-04 16:57:36 UTC ---
Short testcase that is miscompiled:
struct S { int a; int *__restrict p; };
struct S *bar (struct S *);
int
foo (int *p, int *q, int z)
{
struct S s, *t;
s.a = 1;
s.p = p;
t = bar (&s);
t->p = q;
s.p[0] = 0;
t->p[0] = 1;
return s.p[0];
}
If bar returns the parameter it has been passed, s and *t are the same object,
so it must return 1 instead of 0 that 4.6 as well as trunk return.