Bug 64475

Summary: Missed function pointer in the virtual table
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-05-06 14:52:54 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:

Description Grigory Zagorodnev 2002-05-06 14:52:49 UTC
From Bugzilla Helper:
User-Agent: Mozilla/4.0 (compatible; MSIE 5.5; Windows NT 5.0; NetCaptor 
6.5.0PB8)

Description of problem:
Virtual table for the given class W misses second pointer to function W::x.

The class source is:
   struct R {
     virtual void z (void) {}
     virtual void y (void) {}
     virtual R * x (void) { return this; }
   };
   
   struct S : public R { };

   struct W : public S {
     double d;
     virtual long k (void) { return 0l; } 
     W * x (void) { return this; } 
   };

According to the C++ ABI, virtual table should contain "an entry for any 
virtual function declared in a class, whether it is a new function or overrides 
a base class function, unless it overrides a function from the primary base, 
and conversion between their return types does not require an adjustment". [C++ 
ABI, 2.5.2 Virtual Table Components and Order]

g++3 compiler leaves only one pointer to function W::x, i.e. g++3 decides that 
this is the exception case.

But it's not completely clear. further reading of ABI suggests that there 
should be two entries for function 'W::x' for class W and R.



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


How reproducible:
Always

Steps to Reproduce:
Use the testcase

Additional info:

Comment 1 Jakub Jelinek 2002-05-07 17:14:24 UTC
But that's the correct behaviour.
R is W's primary base (there is no multiple inheritance in the example),
likewise conversion from W to R doesn't need any adjustements.