public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "grigory at stl dot sarov dot ru" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug c++/12377] New: Empty base out of class boundaries
Date: Tue, 23 Sep 2003 15:57:00 -0000	[thread overview]
Message-ID: <20030923142930.12377.grigory@stl.sarov.ru> (raw)

PLEASE REPLY TO gcc-bugzilla@gcc.gnu.org ONLY, *NOT* gcc-bugs@gcc.gnu.org.

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=12377

           Summary: Empty base out of class boundaries
           Product: gcc
           Version: 3.3.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: grigory at stl dot sarov dot ru
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: i386-redhat-linux
  GCC host triplet: i386-redhat-linux
GCC target triplet: i386-redhat-linux

Using the 3.2-compatable ABI implementation (-fabi_version=1) g++ compiler may 
alocate empty virtual base out of class boundaries. That seems to be a bug 
rather than a specific implementation.

Let's see: on class hierarchy listed below, g++ 3.3.1 produces class c17 of 
size 16 but allocates c17::c10::c0 base at offset 28.

$ cat foo.cpp
struct c0 { };
struct c2 {
    unsigned char m1;
};
struct c5 : c0, virtual c2 { };
struct c6 { };
struct c9 : c5, c6 { };
struct c10 :
    virtual c2,
    virtual c5,
    virtual c0,
    c9
{
};
struct c17 : virtual c10, c6 { };


$ g++ -c -fdump-class-hierarchy foo.cpp
Class c17
   size=16 align=4
c17 (0x4032d400) 0
    vptridx=0 vptr=((&c17::_ZTV3c17) + 24)
  c10 (0x4032d440) 0 nearly-empty virtual canonical
	...
    c0 (0x4032d5c0) 28 empty virtual canonical

Of cource an empty base does not take any space there, but the class object 
become logically invalid and potentially may lead to run-time problems.


             reply	other threads:[~2003-09-23 14:29 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-09-23 15:57 grigory at stl dot sarov dot ru [this message]
2003-09-23 16:02 ` [Bug c++/12377] [ABI] " bangerth at dealii dot org
2003-09-24  9:13 ` nathan at gcc dot gnu dot org
2003-09-24  9:40 ` nathan at gcc dot gnu dot org
2003-12-09 18:30 ` dhazeghi at yahoo dot com

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=20030923142930.12377.grigory@stl.sarov.ru \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@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: link
Be 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).