Bug 65095 - Virtual table layout: wrong vcall/vbase order for primary base class
Virtual table layout: wrong vcall/vbase order for primary base class
Product: Red Hat Linux
Classification: Retired
Component: gcc3 (Show other bugs)
All Linux
medium Severity high
: ---
: ---
Assigned To: Jakub Jelinek
Depends On:
  Show dependency treegraph
Reported: 2002-05-17 08:13 EDT by Grigory Zagorodnev
Modified: 2008-05-01 11:38 EDT (History)
0 users

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Last Closed: 2002-12-15 15:29:27 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---

Attachments (Terms of Use)
The test case (1021 bytes, text/plain)
2002-05-17 08:14 EDT, Grigory Zagorodnev
no flags Details

  None (edit)
Description Grigory Zagorodnev 2002-05-17 08:13:18 EDT
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; NetCaptor 

Description of problem:
The C++ ABI syas that...

2.5 Virtual Table Layout 
2.5.2 Virtual Table Components and Order 
"However, in classes sharing a virtual table with a primary base class, the 
vcall and vbase offsets added by the derived class all come before the vcall 
and vbase offsets required by the base class, so that the latter may be laid 
out as required by the base class without regard to additions from the derived 
class(es). "

In the attached testcase, P is the primary base for S. So we are following 
quoted rule for vcall/vbase offsets order in it. Expected S's virtual table 
layout is the following (vptr is the virtual table entry point):
	vptr[-4] S's vbase offset
	vptr[-3] P's vcall offset
	vptr[-2] offset to top
	vptr[-1] typeinfo ptr

g++ compiler violates described rule by changing order of P's vcall and S's 
vbase offsets. It gives the following:
	vptr[-4] P's vcall offset
	vptr[-3] S's vbase offset

PS: Hope there is enough information 8-).

Version-Release number of selected component (if applicable):

How reproducible:

Steps to Reproduce:
1. compile testcase 
    g++3 -c fail.cpp

2. Run to see the output

Actual Results:  bad P's vcall offset
bad S's vbase offset

Expected Results:  Passed

Additional info:
Comment 1 Grigory Zagorodnev 2002-05-17 08:14:56 EDT
Created attachment 57724 [details]
The test case
Comment 2 Jason Merrill 2002-06-14 08:37:08 EDT
This testcase is wrong; vptr[-3] is R's vbase pointer in S.

Note You need to log in before you can comment on or make changes to this bug.