This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[RFA:] Fix initialization bug in g++.dg/opt/cleanup1.C
- From: Hans-Peter Nilsson <hans-peter dot nilsson at axis dot com>
- To: gcc-patches at gcc dot gnu dot org
- Date: Sun, 21 Apr 2002 20:34:23 +0200
- Subject: [RFA:] Fix initialization bug in g++.dg/opt/cleanup1.C
There's an initialization bug in g++.dg/opt/cleanup1.C. You may
not usually not see it, since most environments would return
fresh zero-initialized memory from malloc (called by the default
operator new). The CRIS simulator I use when testing cris-elf,
would poison malloc-returned memory, so the test fails a __null
check in main: the c pointers of the C objects h.h.g->f->d.i1
and h.h.g->f->d.i2, that were created using the default C
constructor, didn't have the c members initialized. Here's a
fix. As expected, it seems to affect only code generated for
the the C::C() constructors (the in-charge and not-in-charge
ones), but I think the fix is just beyond the obviousness-
threshold. On using __null rather than 0, it's only because
that's what's used for the test that fails:
if (i == 0 && (p->d.i1.c != __null || p->d.i2.c != __null))
abort ();
Ok to commit, trunk and branch?
* g++.dg/opt/cleanup1.C (C::C()): Initialize member c.
Index: cleanup1.C
===================================================================
RCS file: /cvs/gcc/gcc/gcc/testsuite/g++.dg/opt/cleanup1.C,v
retrieving revision 1.2
diff -p -c -r1.2 cleanup1.C
*** cleanup1.C 10 Apr 2002 21:49:26 -0000 1.2
--- cleanup1.C 21 Apr 2002 18:20:26 -0000
*************** C C::c1 (const char *x, int y)
*** 130,136 ****
return z;
}
! C::C ()
{
}
--- 130,136 ----
return z;
}
! C::C () : c (__null)
{
}
brgds, H-P