This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]