This is the mail archive of the gcc@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]

Re: gcc 3.0.1 & C++ ABI issues


Jason Merrill wrote:
> 
> >>>>> "Mark" == Mark Mitchell <mark@codesourcery.com> writes:
> 
> > What do you think we should do in the 3.0.1 time frame?  Can we get
> > a reasonably safe patch that will fix the correctness issue and
> > not cause the (minor) pessimization?  (This would clearly be the
> > ideal solution.)
> 
> I think a patch that just disables the optimization for the case of copying
> an lvalue of empty class type would be fine for 3.0.1.
This is insufficient. I attach a test case where we assign a
temporary into an empy base, and clobber what it overlays.

nathan


-- 
Dr Nathan Sidwell   ::   http://www.codesourcery.com   ::   CodeSourcery LLC
         'But that's a lie.' - 'Yes it is. What's your point?'
nathan@codesourcery.com : http://www.cs.bris.ac.uk/~nathan/ : nathan@acm.org
struct Empty {};

struct Inter : Empty {};
struct NonPod
{
  int m;

  NonPod () {m = 0x12345678;}
  NonPod (int m_) {m = m_;}
  NonPod &operator= (NonPod const &src) {m = src.m; return *this;}
  NonPod (NonPod const &src) {m = src.m;}
};
struct A : Inter
{
  A (int c) {m = c;}
  
  NonPod m;
};
int main ()
{
  A b (0x32333435);
  (Inter &)b = Inter ();
  if (b.m.m != 0x32333435)
    return 2;	// we copied padding, which clobbered a.m.m
  
  return 0;
}

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