public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/55305] New: invalid aggregate constprop
@ 2012-11-13 1:09 ian at airs dot com
2012-11-13 1:13 ` [Bug tree-optimization/55305] " ian at airs dot com
2012-11-13 14:27 ` jamborm at gcc dot gnu.org
0 siblings, 2 replies; 3+ messages in thread
From: ian at airs dot com @ 2012-11-13 1:09 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55305
Bug #: 55305
Summary: invalid aggregate constprop
Classification: Unclassified
Product: gcc
Version: 4.8.0
Status: UNCONFIRMED
Keywords: wrong-code
Severity: blocker
Priority: P3
Component: tree-optimization
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: ian@airs.com
When I compile and run this program with current mainline with -O0, -O1, or
-Og, it passes. When I use -O2, it crashes.
This is a reduced version of a failure in the libgo testsuite.
extern void exit (int) __attribute__ ((noreturn));
extern void abort (void) __attribute__ ((noreturn));
struct t
{
char dummy;
};
struct m
{
const struct t *t;
void (*m)(void);
};
struct s
{
const struct m *m;
void *o;
};
struct e
{
const struct t *t;
void *o;
};
struct ret
{
struct s s;
_Bool b;
};
const struct t t1 = { 1 };
const struct t t2 = { 2 };
const struct t t3 = { 3 };
const struct t t4 = { 4 };
const struct t t5 = { 5 };
void
pass (void)
{
exit (0);
}
void
fail (void)
{
abort ();
}
const struct m m1 = { &t4, fail };
const struct m m2 = { &t5, pass };
static struct e f2 (struct s s2, void *p);
static struct e f3 (struct s, void *) __attribute__ ((noinline));
static void f4 (struct s, void *) __attribute__ ((noinline));
struct ret c (struct s, const struct t *) __attribute__ ((noinline));
struct ret
c (struct s s1, const struct t *t)
{
struct ret r;
if (s1.m->t == t)
{
r.s.m = &m2;
r.s.o = s1.o;
r.b = 1;
}
else
{
r.s.m = 0;
r.s.o = 0;
r.b = 0;
}
return r;
}
void *m (void) __attribute__ ((noinline));
void *
m (void)
{
return 0;
}
struct e
f1 (struct s s1, void *p)
{
struct ret r;
void *a;
struct s a2;
r = c (s1, &t5);
if (r.b)
return f2 (r.s, p);
a = m ();
a2.m = &m1;
a2.o = a;
return f2 (a2, p);
}
static struct e
f2 (struct s s2, void *p)
{
struct e e1;
e1 = f3 (s2, p);
if (e1.t == &t2 && e1.o == 0)
{
e1.t = 0;
e1.o = 0;
}
return e1;
}
static struct e
f3 (struct s s1, void *p)
{
struct e r;
f4 (s1, p);
r.t = &t3;
r.o = 0;
return r;
}
struct s g1;
void *g2;
static void
f4 (struct s s1, void *p)
{
g1 = s1;
g2 = p;
s1.m->m ();
}
int
main ()
{
struct s s1;
s1.m = &m2;
s1.o = 0;
f1 (s1, 0);
abort ();
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/55305] invalid aggregate constprop
2012-11-13 1:09 [Bug tree-optimization/55305] New: invalid aggregate constprop ian at airs dot com
@ 2012-11-13 1:13 ` ian at airs dot com
2012-11-13 14:27 ` jamborm at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: ian at airs dot com @ 2012-11-13 1:13 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55305
Ian Lance Taylor <ian at airs dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |hubicka at gcc dot gnu.org,
| |jamborm at gcc dot gnu.org
--- Comment #1 from Ian Lance Taylor <ian at airs dot com> 2012-11-13 01:12:46 UTC ---
The bug occurs in the IPA const-prop pass. The compiler incorrectly decides
that f2 always invokes f3 with a constant aggregate parameter. This is
incorrect. There are two calls to f2, and they use different values.
The bug was introduced after 2012-11-05. I suspect this patch:
2012-11-07 Martin Jambor <mjambor@suse.cz>
PR tree-optimization/53787
but I have not proven that that is the problem.
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug tree-optimization/55305] invalid aggregate constprop
2012-11-13 1:09 [Bug tree-optimization/55305] New: invalid aggregate constprop ian at airs dot com
2012-11-13 1:13 ` [Bug tree-optimization/55305] " ian at airs dot com
@ 2012-11-13 14:27 ` jamborm at gcc dot gnu.org
1 sibling, 0 replies; 3+ messages in thread
From: jamborm at gcc dot gnu.org @ 2012-11-13 14:27 UTC (permalink / raw)
To: gcc-bugs
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=55305
Martin Jambor <jamborm at gcc dot gnu.org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |DUPLICATE
--- Comment #2 from Martin Jambor <jamborm at gcc dot gnu.org> 2012-11-13 14:26:51 UTC ---
This is a duplicate of PR 55253, I'm testing a fix.
*** This bug has been marked as a duplicate of bug 55253 ***
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2012-11-13 14:27 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-11-13 1:09 [Bug tree-optimization/55305] New: invalid aggregate constprop ian at airs dot com
2012-11-13 1:13 ` [Bug tree-optimization/55305] " ian at airs dot com
2012-11-13 14:27 ` jamborm at gcc dot gnu.org
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).