public inbox for gcc-prs@sourceware.org help / color / mirror / Atom feed
From: grigory@stl.sarov.ru To: gcc-gnats@gcc.gnu.org Subject: c++/8390: Object layout: empty virtual base allocation failure Date: Mon, 28 Oct 2002 23:36:00 -0000 [thread overview] Message-ID: <20021029072659.6352.qmail@sources.redhat.com> (raw) >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:
next reply other threads:[~2002-10-29 7:36 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2002-10-28 23:36 grigory [this message] 2003-01-23 17:59 jason
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20021029072659.6352.qmail@sources.redhat.com \ --to=grigory@stl.sarov.ru \ --cc=gcc-gnats@gcc.gnu.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
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).