Opened 12 years ago

Closed 12 years ago

Last modified 12 years ago

#10791 closed defect (fixed)

link problems with inline virtual functions

Reported by: sharkcz Owned by:
Priority: normal Milestone:
Component: wxGTK Version: 2.9.0
Keywords: Cc:
Blocked By: Blocking:
Patch: no


I have link problems when building the included test suite (2.9.0-RC3), see the errors below:

g++ -o test test_test.o test_archivetest.o test_ziptest.o test_tartest.o test_arrays.o test_base64.o

test_cmdlinetest.o test_fileconf.o test_datetimetest.o test_evthandler.o test_timertest.o test_exec.o test_filekind.o test_filenametest.o test_filesystest.o test_fontmaptest.o test_formatconvertertest.o tes

t_hashes.o test_intltest.o test_lists.o test_longlongtest.o test_convautotest.o test_mbconvtest.o test_misctests.o test_ipc.o test_socket.o test_regextest.o test_wxregextest.o test_scopeguardtest.o test_iost
ream.o test_strings.o test_stdstrings.o test_tokenizer.o test_unichar.o test_unicode.o test_vararg.o test_crt.o test_vsnprintf.o test_bstream.o test_datastreamtest.o test_ffilestream.o test_fileback.o test_f
ilestream.o test_iostreams.o test_largefile.o test_memstream.o test_socketstream.o test_sstream.o test_tempfile.o test_textstreamtest.o test_zlibstream.o test_textfiletest.o test_atomic.o test_queue.o test_t
ls.o test_uris.o test_vectors.o test_evtconnection.o test_weakref.o test_xlocale.o test_xmltest.o -L/builddir/build/BUILD/wxWidgets-2.9.0-RC3/lib -lcppunit -ldl -pthread -lwx_baseu_net-2.9 -lwx_base
u-2.9 -lwx_baseu_xml-2.9 -lexpat -lwxregexu-2.9 -pthread -Wl,--version-script,/builddir/build/BUILD/wxWidgets-2.9.0-RC3/version-script -lz -ldl -lm -lz -ldl -lm
test_fileconf.o: In function `FileConfigTestCase::ChangePath(wxFileConfig&, wchar_t const*)':
/builddir/build/BUILD/wxWidgets-2.9.0-RC3/tests/./config/fileconf.cpp:112: undefined reference to `wxFileConfig::GetPath() const'
/builddir/build/BUILD/wxWidgets-2.9.0-RC3/tests/./config/fileconf.cpp:112: undefined reference to `wxFileConfig::GetPath() const'
/builddir/build/BUILD/wxWidgets-2.9.0-RC3/tests/./config/fileconf.cpp:112: undefined reference to `wxFileConfig::GetPath() const'
/builddir/build/BUILD/wxWidgets-2.9.0-RC3/tests/./config/fileconf.cpp:112: undefined reference to `wxFileConfig::GetPath() const'
/builddir/build/BUILD/wxWidgets-2.9.0-RC3/tests/./config/fileconf.cpp:112: undefined reference to `wxFileConfig::GetPath() const'
test_fileconf.o:/builddir/build/BUILD/wxWidgets-2.9.0-RC3/tests/./config/fileconf.cpp:112: more undefined references to `wxFileConfig::GetPath() const' follow
collect2: ld returned 1 exit status

The problem is:

mock-chroot> readelf -W -s lib/ | grep wxFileConfig | grep GetPath

681: 00000000000c0fb0 8 FUNC LOCAL HIDDEN 12 _ZNK12wxFileConfig7GetPathEv

It fails on Fedora 10 with gcc 4.3.2 and Fedora Rawhide with gcc 4.4, architecture is x86_64.

full build log and info about build environment are available at

Change History (6)

comment:1 Changed 12 years ago by vadz

Looks like these compilers have a problem with virtual inline functions (FWIW I don't see this problem with Debian gcc 4.3.3 under the same amd64 architecture).

Could you please check if moving wxFileConfig::GetPath() implementation into fileconf.cpp from wx/fileconf.h solve it?


comment:2 follow-up: Changed 12 years ago by sharkcz

Moving the implementation fixes the issue, but then the original code exposes a gcc bug, doesn't it?

comment:3 in reply to: ↑ 2 Changed 12 years ago by vadz

  • Resolution set to fixed
  • Status changed from new to closed
  • Summary changed from link problems in the test-suite to link problems with inline virtual functions

Replying to sharkcz:

Moving the implementation fixes the issue, but then the original code exposes a gcc bug, doesn't it?

IMO it does. I expect it to be difficult to reproduce in small code snippet though as otherwise someone would presumably have noticed it by now... There have been (only! -- this is a pretty good record compared to some other compilers) a couple of cases in the past when we hit g++ bugs but invariably I couldn't reproduce them and so they were not fixed because of the absence of a test case.

Anyhow, for now I'll just move the function out of line but if you can reproduce this bug on your system with simple test code you really should report it to gcc maintainers (please cc me to your bug report if you do, TIA!).

comment:4 Changed 12 years ago by VZ

(In [60643]) move virtual GetPath() implementation out of line to work around an apparent Fedora g++ 4.x bug (see #10791)

comment:5 Changed 12 years ago by csomor

Vadim, this reminds me of the problem I've had on OSX with the gcc visibility flags in the new string class code, in the cases I encountered I think in the end we've just added the export to the virtual, to be explicit.

I think the mechanism was that since the class itself was exported from a different module, the inline would not be resolved in place, but because of the visibility rules, the inline was by itself hidden and not exposed, that's why we had to add the export

comment:6 Changed 12 years ago by vadz

Indeed, maybe adding an explicit wxEXPORT could help here too. OTOH moving it out of line is not a big deal here as the method is virtual and so was probably never inlined anyhow.

Note: See TracTickets for help on using tickets.