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++/8612: Vtable layout: missing vcall offset
Date: Fri, 22 Nov 2002 11:18:00 -0000	[thread overview]
Message-ID: <20021117102154.29434.qmail@sources.redhat.com> (raw)


>Number:         8612
>Category:       c++
>Synopsis:       Vtable layout: missing vcall offset
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Sun Nov 17 02:26:01 PST 2002
>Closed-Date:
>Last-Modified:
>Originator:     Grigory Zagorodnev
>Release:        3.2
>Organization:
>Environment:
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:
'C2' is the virtual base of class 'C1' in the given test-case. So the C2-in-C1 virtual table should contains virtual call (vcall) offsets for all virtual functions defined in C2 and it's subobjects.

Class C4 defines virtual function f6 and this class is included twice in the C2 (as direct and indirect non-virtual base). So two vcall entries are expected in the virtual table. However g++ gives only one entry - see vtable layout below.

That should be considered as a bug.

------------------------
The test-case (test.cpp) 
------------------------
struct C4
{
        int m0;
virtual int f6()        { return 4; }
};

struct C7:  C4
{
        int m0;
};

struct C2: C4, C7
{
        int m0;
};

struct C1: virtual C2
{
        short m1;
};

C1 o1;

--------------------
Virtual table layout
--------------------
$ g++ -c -fdump-class-hierarchy test.cpp
$ cat test.cpp.class

Vtable for C1
C1::_ZTV2C1: 10 entries
0     8
4     0
8     &_ZTI2C1
12    8		< -- f6's vcall offset. Why only one?
16    0fffffff8
20    &_ZTI2C1	< -- C2-in-C1 vtable entry point
24    C4::f6()
28    0fffffff0
32    &_ZTI2C1
36    C4::f6()

Class C1
   size=32 align=4
C1 (0x40323200) 0
    vptridx=0 vptr=((&C1::_ZTV2C1) + 12)
  C2 (0x40323240) 8 virtual canonical
      vptridx=4 vbaseoffset=-12 vptr=((&C1::_ZTV2C1) + 24)
    C4 (0x40323300) 8
        primary-for C2 (0x40323240)
    C7 (0x40323280) 16
        vptridx=8 vptr=((&C1::_ZTV2C1) + 36)
      C4 (0x403232c0) 16
          primary-for C7 (0x40323280)
>How-To-Repeat:

>Fix:

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


             reply	other threads:[~2002-11-17 10:26 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-11-22 11:18 grigory [this message]
2003-02-04 20:57 nathan

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=20021117102154.29434.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: 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).