Bug 65095

Summary: Virtual table layout: wrong vcall/vbase order for primary base class
Product: [Retired] Red Hat Linux Reporter: Grigory Zagorodnev <grigory_zagorodnev>
Component: gcc3Assignee: Jakub Jelinek <jakub>
Status: CLOSED NOTABUG QA Contact:
Severity: high Docs Contact:
Priority: medium    
Version: 7.2   
Target Milestone: ---   
Target Release: ---   
Hardware: All   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2002-12-15 20:29:27 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
The test case none

Description Grigory Zagorodnev 2002-05-17 12:13:18 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; NetCaptor 
6.5.0PB8)

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:
Always

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 12:14:56 UTC
Created attachment 57724 [details]
The test case

Comment 2 Jason Merrill 2002-06-14 12:37:08 UTC
This testcase is wrong; vptr[-3] is R's vbase pointer in S.