public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13118] New: Missed covariant return thunk
@ 2003-11-19 8:37 grigory at stl dot sarov dot ru
2003-11-19 14:33 ` [Bug c++/13118] [ABI] " bangerth at dealii dot org
` (8 more replies)
0 siblings, 9 replies; 10+ messages in thread
From: grigory at stl dot sarov dot ru @ 2003-11-19 8:37 UTC (permalink / raw)
To: gcc-bugs
For routine f6 of class c28 in the hirarchy listed below it is expected 5
covariant thunks to be emitted.
covariant return thunk [nv:0] [v:0,-12] to c28::f6()
covariant return thunk [nv:0] [v:0,-16] to c28::f6()
covariant return thunk [v:0,-16] [v:0,-16] to c28::f6()
covariant return thunk [v:0,-24] [v:0,-12] to c28::f6()
covariant return thunk [v:0,-24] [v:0,-16] to c28::f6()
However G++ 3.4 compiler misses (does not generate) the last thunk from the
list. This seems to be a C++ ABI failure.
$ cat test.cpp
struct c0 {};
struct c1 : virtual c0 {
virtual class ::c0* f6() {};
};
struct c5 {
virtual void foo(){};
};
struct c10 : virtual c1 {
virtual void foo(){};
};
struct c11 : virtual c10, c1 {
int i;
virtual c1* f6() {}
};
struct c18 : c5, virtual c1 {
virtual void bar(){};
};
struct c28 : virtual c0, virtual c11 {
virtual c18* f6() {};
} obj;
$ g++ -c test.cpp
$ nm test.o | grep "_ZTc.*c282f6"
00000006 W _ZTch0_v0_n12_N3c282f6Ev
00000036 W _ZTch0_v0_n16_N3c282f6Ev
00000056 W _ZTcv0_n16_v0_n16_N3c282f6Ev
00000026 W _ZTcv0_n24_v0_n12_N3c282f6Ev
There is no expected thunk "_ZTcv0_n24_v0_n12_N3c282f6Ev" generated.
--
Summary: Missed covariant return thunk
Product: gcc
Version: 3.4
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: grigory at stl dot sarov dot ru
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-redhat-linux
GCC host triplet: i686-redhat-linux
GCC target triplet: i686-redhat-linux
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
@ 2003-11-19 14:33 ` bangerth at dealii dot org
2003-11-19 16:32 ` pinskia at gcc dot gnu dot org
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: bangerth at dealii dot org @ 2003-11-19 14:33 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
Summary|Missed covariant return |[ABI] Missed covariant
|thunk |return thunk
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
2003-11-19 14:33 ` [Bug c++/13118] [ABI] " bangerth at dealii dot org
@ 2003-11-19 16:32 ` pinskia at gcc dot gnu dot org
2003-11-21 9:16 ` nathan at gcc dot gnu dot org
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-19 16:32 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-11-19 16:32 -------
Nathan, covariant return thunks are yours.
--
What |Removed |Added
----------------------------------------------------------------------------
CC| |nathan at gcc dot gnu dot
| |org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
2003-11-19 14:33 ` [Bug c++/13118] [ABI] " bangerth at dealii dot org
2003-11-19 16:32 ` pinskia at gcc dot gnu dot org
@ 2003-11-21 9:16 ` nathan at gcc dot gnu dot org
2003-11-21 9:33 ` nathan at gcc dot gnu dot org
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-11-21 9:16 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From nathan at gcc dot gnu dot org 2003-11-21 09:16 -------
confirmed.
the c11-c28-c28 secondary vtable has two slots for f6. The first
was added by the c1-c1-c1 vtable and expects a c0 pointer return.
The second was added by the c11-c11-c11 vtable and expects
a c1 pointer return. (c0 is a virtual base of c1).
c11-c28-c28's first slot should point to the missing c0 in c18 adjusting
thunk (0,-24,0,-16). The second slot should point to the c1 in c18
adjusting thunk (0,-14,0,-12).
I'll try and attach a testcase that checks things at runtime.
--
What |Removed |Added
----------------------------------------------------------------------------
Priority|P2 |P1
Target Milestone|--- |3.4
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
` (2 preceding siblings ...)
2003-11-21 9:16 ` nathan at gcc dot gnu dot org
@ 2003-11-21 9:33 ` nathan at gcc dot gnu dot org
2003-11-21 14:29 ` pinskia at gcc dot gnu dot org
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-11-21 9:33 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From nathan at gcc dot gnu dot org 2003-11-21 09:33 -------
Created an attachment (id=5180)
--> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5180&action=view)
test case
this test case should succeed. on 3.4 it fails with exit code 1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
` (3 preceding siblings ...)
2003-11-21 9:33 ` nathan at gcc dot gnu dot org
@ 2003-11-21 14:29 ` pinskia at gcc dot gnu dot org
2003-11-22 14:46 ` grigory at stl dot sarov dot ru
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2003-11-21 14:29 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From pinskia at gcc dot gnu dot org 2003-11-21 14:29 -------
Confirmed.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |NEW
Ever Confirmed| |1
Last reconfirmed|0000-00-00 00:00:00 |2003-11-21 14:29:10
date| |
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
` (4 preceding siblings ...)
2003-11-21 14:29 ` pinskia at gcc dot gnu dot org
@ 2003-11-22 14:46 ` grigory at stl dot sarov dot ru
2003-12-12 14:54 ` nathan at gcc dot gnu dot org
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: grigory at stl dot sarov dot ru @ 2003-11-22 14:46 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From grigory at stl dot sarov dot ru 2003-11-22 14:46 -------
There is another example illustrating the same problem.
In the hierarchy listed below, c3 shares virtual table both with c2 and c1
bases. That is c3 v-table introduces 3 slots for covariant return type function
"foo". First and second slots contain pointer to adjustment thunks and third one
contains pointer to non-adjusting entry.
[0] c1-in-c2-in-c3::foo, returning r1-in-r3
[1] c2-in-c3::foo, returning r2-in-r3
[2] c3::foo, returning r3-in-r3
However the actually generated vtable for c3 contains pointer to wrong thunk in
the first slot:
[skip]
16 c3::_ZTcv0_n12_v0_n12_N2c33fooEv
20 c3::_ZTcv0_n12_v0_n12_N2c33fooEv
24 c3::foo
Basing on thunk encoding "v0_n12_v0_n12_", contents of c3's and r3's virtual
tables we can say that "this" value will be incorrectly adjusted to c2-in-c3 and
the return value will be adjusted to r2 instead of r1 in the r3's hierarchy.
I.e. actually used thunk appears to be:
c1-in-c2::foo, returning r1-in-r2
It looks like g++ 3.4 compiler just inherits this slot value from the vtable of
base class c2 introduced as complete object.
Vtable for c2
[skip]
16 c2::_ZTcv0_n12_v0_n12_N2c23fooEv
20 c2::foo
Class hierarchy
---------------
struct r1 {
int j;
virtual ~r1();
};
struct r2 : virtual r1 {
int j;
virtual ~r2();
};
struct r3 : virtual r2, virtual r1 {
int i;
};
struct c1 {
virtual r1& foo() {};
};
struct c2 : virtual c1 {
virtual r2& foo() {};
};
struct c3 : c2 {
virtual r3& foo() {};
};
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
` (5 preceding siblings ...)
2003-11-22 14:46 ` grigory at stl dot sarov dot ru
@ 2003-12-12 14:54 ` nathan at gcc dot gnu dot org
2003-12-12 18:22 ` cvs-commit at gcc dot gnu dot org
2003-12-12 18:43 ` nathan at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-12-12 14:54 UTC (permalink / raw)
To: gcc-bugs
--
What |Removed |Added
----------------------------------------------------------------------------
AssignedTo|unassigned at gcc dot gnu |nathan at gcc dot gnu dot
|dot org |org
Status|NEW |ASSIGNED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
` (6 preceding siblings ...)
2003-12-12 14:54 ` nathan at gcc dot gnu dot org
@ 2003-12-12 18:22 ` cvs-commit at gcc dot gnu dot org
2003-12-12 18:43 ` nathan at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2003-12-12 18:22 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From cvs-commit at gcc dot gnu dot org 2003-12-12 18:22 -------
Subject: Bug 13118
CVSROOT: /cvs/gcc
Module name: gcc
Changes by: nathan@gcc.gnu.org 2003-12-12 18:22:24
Modified files:
gcc/cp : ChangeLog cp-tree.h class.c method.c
semantics.c
gcc/testsuite : ChangeLog
Added files:
gcc/testsuite/g++.dg/abi: covariant3.C
Log message:
cp:
PR c++/13118
* cp-tree.h (lang_decl_u): Add thunk_alias member.
(THUNK_VIRTUAL_OFFSET): Must be a FUNCTION_DECL.
(THUNK_ALIAS_P): Remove.
(THUNK_ALIAS): Adjust.
* class.c (update_vtable_entry_for_fn): Get the vbase within the
overriding function's return type.
(dump_thunk): Adjust THUNK_ALIAS printing.
(build_vtbl_initializer): Adjust THUNK_ALIAS use.
* method.c (make_thunk): Revert 12881 test change. Clear
THUNK_ALIAS.
(finish_thunk): Adjust THUNK_ALIAS setting.
(use_thunk): Adjust THUNK_ALIAS use.
* semantics.c (emit_associated_thunks): Likewise.
testsuite:
PR c++/13118
* g++.dg/abi/covariant3.C: New.
Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/ChangeLog.diff?cvsroot=gcc&r1=1.3796&r2=1.3797
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/cp-tree.h.diff?cvsroot=gcc&r1=1.938&r2=1.939
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/class.c.diff?cvsroot=gcc&r1=1.585&r2=1.586
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/method.c.diff?cvsroot=gcc&r1=1.272&r2=1.273
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/cp/semantics.c.diff?cvsroot=gcc&r1=1.374&r2=1.375
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.3249&r2=1.3250
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/g++.dg/abi/covariant3.C.diff?cvsroot=gcc&r1=NONE&r2=1.1
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
* [Bug c++/13118] [ABI] Missed covariant return thunk
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
` (7 preceding siblings ...)
2003-12-12 18:22 ` cvs-commit at gcc dot gnu dot org
@ 2003-12-12 18:43 ` nathan at gcc dot gnu dot org
8 siblings, 0 replies; 10+ messages in thread
From: nathan at gcc dot gnu dot org @ 2003-12-12 18:43 UTC (permalink / raw)
To: gcc-bugs
------- Additional Comments From nathan at gcc dot gnu dot org 2003-12-12 18:42 -------
2003-12-12 Nathan Sidwell <nathan@codesourcery.com>
PR c++/13118
* cp-tree.h (lang_decl_u): Add thunk_alias member.
(THUNK_VIRTUAL_OFFSET): Must be a FUNCTION_DECL.
(THUNK_ALIAS_P): Remove.
(THUNK_ALIAS): Adjust.
* class.c (update_vtable_entry_for_fn): Get the vbase within the
overriding function's return type.
(dump_thunk): Adjust THUNK_ALIAS printing.
(build_vtbl_initializer): Adjust THUNK_ALIAS use.
* method.c (make_thunk): Revert 12881 test change. Clear
THUNK_ALIAS.
(finish_thunk): Adjust THUNK_ALIAS setting.
(use_thunk): Adjust THUNK_ALIAS use.
* semantics.c (emit_associated_thunks): Likewise.
--
What |Removed |Added
----------------------------------------------------------------------------
Status|ASSIGNED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13118
^ permalink raw reply [flat|nested] 10+ messages in thread
end of thread, other threads:[~2003-12-12 18:43 UTC | newest]
Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-19 8:37 [Bug c++/13118] New: Missed covariant return thunk grigory at stl dot sarov dot ru
2003-11-19 14:33 ` [Bug c++/13118] [ABI] " bangerth at dealii dot org
2003-11-19 16:32 ` pinskia at gcc dot gnu dot org
2003-11-21 9:16 ` nathan at gcc dot gnu dot org
2003-11-21 9:33 ` nathan at gcc dot gnu dot org
2003-11-21 14:29 ` pinskia at gcc dot gnu dot org
2003-11-22 14:46 ` grigory at stl dot sarov dot ru
2003-12-12 14:54 ` nathan at gcc dot gnu dot org
2003-12-12 18:22 ` cvs-commit at gcc dot gnu dot org
2003-12-12 18:43 ` nathan at gcc dot gnu dot org
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).