This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c++/65009] New: g++ 4.9 sometimes leaves inline methods undefined when compiling with -Os
- From: "truckman at FreeBSD dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 10 Feb 2015 23:22:56 +0000
- Subject: [Bug c++/65009] New: g++ 4.9 sometimes leaves inline methods undefined when compiling with -Os
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65009
Bug ID: 65009
Summary: g++ 4.9 sometimes leaves inline methods undefined when
compiling with -Os
Product: gcc
Version: 4.9.3
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c++
Assignee: unassigned at gcc dot gnu.org
Reporter: truckman at FreeBSD dot org
# g++49 -v
Using built-in specs.
COLLECT_GCC=g++49
COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc49/gcc/i386-portbld-freebsd8.4/4.9.3/lto-wrapper
Target: i386-portbld-freebsd8.4
Configured with: ./../gcc-4.9-20150204/configure
--with-build-config=bootstrap-debug --disable-nls
--enable-gnu-indirect-function --libdir=/usr/local/lib/gcc49
--libexecdir=/usr/local/libexec/gcc49 --program-suffix=49
--with-as=/usr/local/bin/as --with-gmp=/usr/local
--with-gxx-include-dir=/usr/local/lib/gcc49/include/c++/
--with-ld=/usr/local/bin/ld --with-libiconv-prefix=/usr/local
--with-pkgversion='FreeBSD Ports Collection' --with-system-zlib
--with-ecj-jar=/usr/local/share/java/ecj-4.5.jar
--enable-languages=c,c++,objc,fortran,java --prefix=/usr/local
--mandir=/usr/local/man --infodir=/usr/local/info/gcc49
--build=i386-portbld-freebsd8.4
Thread model: posix
gcc version 4.9.3 20150204 (prerelease) (FreeBSD Ports Collection)
When compiling at the -Os optimization level, g++ 4.9 sometimes leaves
undefined symbols in the resulting .o file. In the example below, this causing
a fatal linker error when trying to build a shared library that includes this
.o file. This problem does not occur when compiling with -O0 optimization, and
does not occur with g++ 4.8.
In this example, the following class methods are inline:
KeyListenerMultiplexer::acquire()
FocusListenerMultiplexer::acquire()
MouseListenerMultiplexer::acquire()
PaintListenerMultiplexer::acquire()
WindowListenerMultiplexer::acquire()
MouseMotionListenerMultiplexer::acquire()
When the code is compiled with g++ 4.9 and -Os, the .o file contains undefined
symbols for them. This does not happen with g++ 4.8 or when compiling with
-O0.
Broken:
# g++49 -fPIC -fmessage-length=0 -fno-common -fno-strict-aliasing
-fno-use-cxa-atexit -fvisibility-inlines-hidden -fvisibility=hidden
-fexceptions -fno-enforce-eh-specs -Os -c fmgridif.ii -Wall -o fmgridif.o
# nm fmgridif.o | grep 'ListenerMultiplexer' U
_ZThn24_N22KeyListenerMultiplexer7acquireEv
U _ZThn24_N24FocusListenerMultiplexer7acquireEv
U _ZThn24_N24MouseListenerMultiplexer7acquireEv
U _ZThn24_N24PaintListenerMultiplexer7acquireEv
U _ZThn24_N25WindowListenerMultiplexer7acquireEv
U _ZThn24_N30MouseMotionListenerMultiplexer7acquireEv
#
Works:
# g++49 -fPIC -fmessage-length=0 -fno-common -fno-strict-aliasing
-fno-use-cxa-atexit -fvisibility-inlines-hidden -fvisibility=hidden
-fexceptions -fno-enforce-eh-specs -O0 -c fmgridif.ii -Wall -o fmgridif.o
# nm fmgridif.o | grep 'ListenerMultiplexer'
#
Works:
# g++48 -fPIC -fmessage-length=0 -fno-common -fno-strict-aliasing
-fno-use-cxa-atexit -fvisibility-inlines-hidden -fvisibility=hidden
-fexceptions -fno-enforce-eh-specs -Os -c fmgridif.ii -Wall -o fmgridif.o
# nm fmgridif.o | grep 'ListenerMultiplexer'
#