public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/8390: Object layout: empty virtual base allocation failure
@ 2003-01-23 17:59 jason
  0 siblings, 0 replies; 2+ messages in thread
From: jason @ 2003-01-23 17:59 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, grigory, nobody

Synopsis: Object layout: empty virtual base allocation failure

State-Changed-From-To: feedback->closed
State-Changed-By: jason
State-Changed-When: Thu Jan 23 17:59:56 2003
State-Changed-Why:
    no feedback; the new output looks right.

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=8390


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

* c++/8390: Object layout: empty virtual base allocation failure
@ 2002-10-28 23:36 grigory
  0 siblings, 0 replies; 2+ messages in thread
From: grigory @ 2002-10-28 23:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         8390
>Category:       c++
>Synopsis:       Object layout: empty virtual base allocation failure
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Oct 28 23:36:00 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Grigory Zagorodnev
>Release:        3.2
>Organization:
>Environment:
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i386-redhat-linux/3.2/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --enable-shared --enable-threads=posix --disable-checking --host=i386-redhat-linux --with-system-zlib --enable-__cxa_atexit
Thread model: posix
gcc version 3.2 20020903 (Red Hat Linux 8.0 3.2-7)
>Description:
In the test-case listed below, G++ 3.2 compiler makes wrong layout of class C4. Empty virtual base C3 takes non-empty space.

--- fail.cpp ------------------------
struct C3
{
};

struct C2:  C3
{
    virtual int f1() { return 2; }
};

struct C4:  C2, virtual C3
{
        short m1;
        C4() { m1 = (short) 0x4444; }
};

C4 obj;
-------------------------------------

Object layout (got from "g++ -fdump-class-hierarchy -c fail.cpp") is:
	Class C4
	   size=12 align=4
	C4 (0x4031cc00) 0
	    vptridx=0 vptr=((&C4::_ZTV2C4) + 12)
	  C2 (0x4031cc40) 0 nearly-empty
	      primary-for C4 (0x4031cc00)
	    C3 (0x4031cc80) 0 empty
	  C3 (0x4031ccc0) 8 empty virtual canonical
	      vbaseoffset=-12

The binary dump of object is:
	[obj+0x00] Virtual table _ZTV2C4, adress point 0xc
	[obj+0x04] 00004444
	[obj+0x08] 00000000


We see that virtual base C3 is allocated at offset 8 and takes 4 bytes. There is the misstake - C3 should not take any space here!

Expected layout is (binary format):
	[obj+0x00] Virtual table _ZTV2C4, adress point 0xc
	[obj+0x04] 00004444
>How-To-Repeat:

>Fix:

>Release-Note:
>Audit-Trail:
>Unformatted:


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

end of thread, other threads:[~2003-01-23 17:59 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-01-23 17:59 c++/8390: Object layout: empty virtual base allocation failure jason
  -- strict thread matches above, loose matches on Subject: below --
2002-10-28 23:36 grigory

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