This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/26755] New: [4.1 regression?] may fail to generate code for base destructor defined inline
- From: "debian-gcc at lists dot debian dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 19 Mar 2006 12:15:38 -0000
- Subject: [Bug c++/26755] New: [4.1 regression?] may fail to generate code for base destructor defined inline
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[ no small test case yet, forwarded from http://bugs.debian.org/356435 ]
Where a base class has a destructor defined inline, g++ may generate
code for a derived class's destructor that calls an non-inline version
of the base class destructor, but without generating code for the
latter. This is normally masked by the fact that g++ 4.1 now
generates the base-class destructor (aka the non-in-charge destructor)
along with the whole-object destructor (aka the in-charge
destructor), but becomes a problem when linking with code generated by
g++ 4.0.
An example for this is bug #356245 (xbsql failing to build):
> Automatic build of xbsql_0.11-5 on bigsur by sbuild/mips 1.80
...
> /bin/sh ../libtool --mode=link g++ -UNO_READLINE -I/usr/local/include -g -g -o xql xql.o -lxbase -lreadline -lncurses ./libxbsql.la
> g++ -UNO_READLINE -I/usr/local/include -g -g -o .libs/xql xql.o -lreadline -lncurses ./.libs/libxbsql.so /usr/lib/libxbase.so
> ./.libs/libxbsql.so: undefined reference to `xbNdx::~xbNdx()'
> collect2: ld returned 1 exit status
> make[2]: *** [xql] Error 1
Ben Hutchings:
I was scratching my head over this one for a long time, because
libxbase.so definitely does include an out-of-line copy of the
destructor (required for the vtable). Eventually I remembered that the
destructor can be called in several different ways and that the G++ ABI
provides separate entry points, each with its own symbol, for those
different cases. These aren't distinguished when demangling, so we must
turn that off to see that:
libxbase built with g++ 4.0 has:
0001e940 W _ZN5xbNdxD0Ev // deleting destructor
0001eb30 W _ZN5xbNdxD1Ev // complete object destructor
libxbsql built with g++ 4.0 has:
00015676 W _ZN5xbNdxD1Ev // complete object destructor
00012aec W _ZN5xbNdxD2Ev // base object destructor
libxbase (built with g++ 4.1) has:
0001f850 W _ZN5xbNdxD0Ev // deleting destructor
0001f8e0 W _ZN5xbNdxD1Ev // complete object destructor
0001f960 W _ZN5xbNdxD2Ev // base object destructor
libxbsql (built with g++ 4.1) has:
U _ZN5xbNdxD1Ev // complete object destructor
U _ZN5xbNdxD2Ev // base object destructor
It appears that g++ 4.1 generates out-of-line code for all inline
destructors along with other members of the class and relies on that
avoid generating duplicates elsewhere. But g++ 4.1 is supposed to be
binary-compatible with g++ 4.0 and this behaviour isn't, so this is a
bug in g++.
Ben.
--
Summary: [4.1 regression?] may fail to generate code for base
destructor defined inline
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: debian-gcc at lists dot debian dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=26755