public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* C++ ABI change since 3.2 with no warning
@ 2002-10-04 17:02 Janis Johnson
  2002-10-08 13:09 ` Mark Mitchell
  0 siblings, 1 reply; 2+ messages in thread
From: Janis Johnson @ 2002-10-04 17:02 UTC (permalink / raw)
  To: gcc

While working on C++ compatibility tests I broke up g++.dg/init/empty1.C
into this set of source files.  This test passes when everything is
built with either GCC 3.2 or with the mainline but fails when empty1_x.C
is compiled with GCC 3.2 and the rest is built with the mainline.  The
original test is for a PR that was fixed in 3.0.2.  The failure is due
to a change in alignment.  Is this expected?  Should it get a warning
with -Wabi for having changed since GCC 3.2?

Janis

--- empty1.h -----------------------------------------------------------
class EmptyBase0 {};

class EmptyBase1 : public EmptyBase0 {};

class Base1 {
public:
  unsigned int t_;
  Base1(unsigned int);
};

class PEPE : public Base1, public EmptyBase1 {
public:
  PEPE(unsigned int);
};
--- empty1_main.C ------------------------------------------------------
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 3 Sept 2001 <nathan@codesourcery.com>
// Split into pieces for binary compatibility testing October 2002

// Bug 4203. We were bit copying empty bases including the
// padding. Which clobbers whatever they overlay.

extern void empty1_x (void);

int
main ()
{
  empty1_x ();
}
--- empty1_x.C ---------------------------------------------------------
extern "C" void abort (void);

#include "empty1.h"

void
empty1_x ()
{
  PEPE pepe(0xff);
  
  if (pepe.t_ != 255)
    abort ();
}
--- empty1_y.C ---------------------------------------------------------
#include "empty1.h"

Base1::Base1(unsigned int t) : t_(t) {}
PEPE::PEPE(unsigned int t) : Base1(t), EmptyBase1(EmptyBase1()) {}
------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: C++ ABI change since 3.2 with no warning
  2002-10-04 17:02 C++ ABI change since 3.2 with no warning Janis Johnson
@ 2002-10-08 13:09 ` Mark Mitchell
  0 siblings, 0 replies; 2+ messages in thread
From: Mark Mitchell @ 2002-10-08 13:09 UTC (permalink / raw)
  To: Janis Johnson, gcc



--On Friday, October 04, 2002 04:17:06 PM -0700 Janis Johnson 
<janis187@us.ibm.com> wrote:

> While working on C++ compatibility tests I broke up g++.dg/init/empty1.C
> into this set of source files.  This test passes when everything is
> built with either GCC 3.2 or with the mainline but fails when empty1_x.C
> is compiled with GCC 3.2 and the rest is built with the mainline.  The
> original test is for a PR that was fixed in 3.0.2.  The failure is due
> to a change in alignment.  Is this expected?

I think so; we intentionally fixed the alignment of certain tiny classes,
in both C and C++ on the mainline recently.

If we're going to warn about it, we should do it in both C and C++.

I'll take a look at it when I get home and make sure that this is what
it is.

-- 
Mark Mitchell                mark@codesourcery.com
CodeSourcery, LLC            http://www.codesourcery.com


--- empty1.h -----------------------------------------------------------
class EmptyBase0 {};

class EmptyBase1 : public EmptyBase0 {};

class Base1 {
public:
  unsigned int t_;
  Base1(unsigned int);
};

class PEPE : public Base1, public EmptyBase1 {
public:
  PEPE(unsigned int);
};
--- empty1_main.C ------------------------------------------------------
// Copyright (C) 2001 Free Software Foundation, Inc.
// Contributed by Nathan Sidwell 3 Sept 2001 <nathan@codesourcery.com>
// Split into pieces for binary compatibility testing October 2002

// Bug 4203. We were bit copying empty bases including the
// padding. Which clobbers whatever they overlay.

extern void empty1_x (void);

int
main ()
{
  empty1_x ();
}
--- empty1_x.C ---------------------------------------------------------
extern "C" void abort (void);

#include "empty1.h"

void
empty1_x ()
{
  PEPE pepe(0xff);

  if (pepe.t_ != 255)
    abort ();
}
--- empty1_y.C ---------------------------------------------------------
#include "empty1.h"

Base1::Base1(unsigned int t) : t_(t) {}
PEPE::PEPE(unsigned int t) : Base1(t), EmptyBase1(EmptyBase1()) {}
------------------------------------------------------------------------ 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2002-10-08 18:09 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-10-04 17:02 C++ ABI change since 3.2 with no warning Janis Johnson
2002-10-08 13:09 ` Mark Mitchell

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).