This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/22237] New: [4.0/4.1 Regression] struct copy inlining generates overlapping memcpy
- From: "jsm28 at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Jun 2005 23:11:32 -0000
- Subject: [Bug tree-optimization/22237] New: [4.0/4.1 Regression] struct copy inlining generates overlapping memcpy
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The following test should execute successfully (see C99 6.8.6.4#3 and #4: a
return statement is not an assignment so can be used to copy between overlapping
structures - added in C90 TC1 following DR#001). With 4.0 branch and mainline,
it aborts when compiled at -O3 (maybe other levels as well) because the
assignment via an inline function call has been wrongly optimized to a direct
assignment. gcc.c-torture/execute/20010124-1.c used to test for such an issue,
but it now all gets optimized away so a more complicated test such as this one
is needed.
extern void abort (void);
extern void exit (int);
struct s { unsigned char a[256]; };
union u { struct { struct s b; int c; } d; struct { int c; struct s b; } e; };
union u v;
union u v0;
struct s *p = &v.d.b;
struct s *q = &v.e.b;
static inline struct s rp (void) { return *p; }
static inline struct s rq (void) { return *q; }
void pq (void) { *p = rq(); }
void qp (void) { *q = rp(); }
void
init (struct s *sp)
{
int i;
for (i = 0; i < 256; i++)
sp->a[i] = i;
}
void
check (struct s *sp)
{
int i;
for (i = 0; i < 256; i++)
if (sp->a[i] != i)
abort ();
}
int
main (void)
{
v = v0;
init (p);
qp ();
check (q);
v = v0;
init (q);
pq ();
check (p);
exit (0);
}
--
Summary: [4.0/4.1 Regression] struct copy inlining generates
overlapping memcpy
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: jsm28 at gcc dot gnu dot org
CC: gcc-bugs at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=22237