public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
* Re: c++/7470: Vtable: virtual function pointers not in declaration order
@ 2002-08-02  3:54 nathan
  0 siblings, 0 replies; 4+ messages in thread
From: nathan @ 2002-08-02  3:54 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, grigory, nobody

Synopsis: Vtable: virtual function pointers not in declaration order

State-Changed-From-To: open->analyzed
State-Changed-By: nathan
State-Changed-When: Fri Aug  2 03:54:24 2002
State-Changed-Why:
    confirmed. an ABI bug

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7470


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/7470: Vtable: virtual function pointers not in declaration order
@ 2002-09-13 16:52 nathan
  0 siblings, 0 replies; 4+ messages in thread
From: nathan @ 2002-09-13 16:52 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, grigory, nathan

Synopsis: Vtable: virtual function pointers not in declaration order

State-Changed-From-To: analyzed->closed
State-Changed-By: nathan
State-Changed-When: Fri Sep 13 16:52:40 2002
State-Changed-Why:
    now fixed

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7470


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: c++/7470: Vtable: virtual function pointers not in declaration order
@ 2002-08-02  8:04 nathan
  0 siblings, 0 replies; 4+ messages in thread
From: nathan @ 2002-08-02  8:04 UTC (permalink / raw)
  To: gcc-bugs, gcc-prs, grigory, nathan, nobody

Synopsis: Vtable: virtual function pointers not in declaration order

Responsible-Changed-From-To: unassigned->nathan
Responsible-Changed-By: nathan
Responsible-Changed-When: Fri Aug  2 08:04:24 2002
Responsible-Changed-Why:
    patching

http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=7470


^ permalink raw reply	[flat|nested] 4+ messages in thread

* c++/7470: Vtable: virtual function pointers not in declaration order
@ 2002-08-02  2:36 grigory
  0 siblings, 0 replies; 4+ messages in thread
From: grigory @ 2002-08-02  2:36 UTC (permalink / raw)
  To: gcc-gnats


>Number:         7470
>Category:       c++
>Synopsis:       Vtable: virtual function pointers not in declaration order
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Fri Aug 02 02:36:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Grigory Zagorodnev
>Release:        3.1.1
>Organization:
>Environment:
Red Hat Linux release 7.1 (Seawolf)
Kernel 2.4.2-2smp on a 2-processor i686

gcc version 3.1.1
Configured with: ./configure --prefix=/usr/local --program-suffix=-3.1.1 --enable-threads
Thread model: posix
>Description:
The C++ ABI defines order of virtual function pointers in such way:
"2.5.2 Virtual Table Components and Order 
The order of the virtual function pointers in a virtual table is the order of declaration of the corresponding member functions in the class. There is 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."

*** G++ 3.1.1 compiler violates given rules ***

Let's consider the example. 

--- fail.cpp ----------------------
	struct base 
	{
		short b;
		virtual int foo() {}
	};

	struct derived:  virtual base
	{
		int d;
		virtual int foo() {}
		virtual int bar() {}
	};
-----------------------------------

Note that function declaration order is "foo, bar" and 'base' is not the primary base class for 'derived', since it's not nearly empty class.

New we check the virtual table for 'derived' class using "g++-3.1.1 -c -fdump-class-hierarchy fail.cpp".
The virtual table is:

	Vtable for derived
	derived::_ZTV7derived: 9 entries
	0     8
	4     0
	8     &_ZTI7derived
	12    derived::bar()
	16    derived::foo()
	20    0fffffff8
	24    0fffffff8
	28    &_ZTI7derived
	32    derived::_ZTv0_n12_N7derived3fooEv()

We see that virtual functions appear in the order "bar, foo" which is wrong. It's expected to have functions in the declaration order as spcified by the ABI.
>How-To-Repeat:
1. Compile given testcase
g++-3.1.1 -c -fdump-class-hierarchy fail.cpp

2. Look for 'derived' virtual table in the produced fail.cpp.class file
>Fix:

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


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2002-09-13 23:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-08-02  3:54 c++/7470: Vtable: virtual function pointers not in declaration order nathan
  -- strict thread matches above, loose matches on Subject: below --
2002-09-13 16:52 nathan
2002-08-02  8:04 nathan
2002-08-02  2:36 grigory

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).