https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86126
Bug ID: 86126 Summary: Note when linking libraries built with different -std options Product: gcc Version: 8.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: gburca-gnu at ebixio dot com Target Milestone: --- Created attachment 44265 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=44265&action=edit Bug demo Linking together libraries that have been built with LTO and different -std options causes g++ to issue notes of the form: type 'A' should match type 'A'. Specifically, with code below, the output is: ..../gcc/8.1.0-1/include/c++/8.1.0/sstream:80:57: note: type ‘struct __string_type’ should match type ‘struct __string_type’ typedef basic_string<char_type, _Traits, _Alloc> __string_type; ^ ..../gcc/8.1.0-1/include/c++/8.1.0/sstream:540:57: note: type ‘struct __stringbuf_type’ should match type ‘struct __stringbuf_type’ typedef basic_stringbuf<_CharT, _Traits, _Alloc> __stringbuf_type; ^ I've tested with gcc 7.2.0 and it also issues a note about 'struct __string_type' Based on what I see at https://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html and https://stackoverflow.com/questions/46746878/is-it-safe-to-link-c17-c14-and-c11-objects/49119902#49119902 it should be possible to link together objects built with the same compiler but different -std options. The libraries are built with: g++ -fPIC -c liba.cpp -std=gnu++14 -o a.o ${CFLAGS} g++ -fPIC -c libb.cpp -std=gnu++17 -o b.o ${CFLAGS} ar cru liba.a a.o ar cru libb.a b.o They are linked together with: g++ main.cpp -std=gnu++17 -L. -la -lb -o main ${CFLAGS} -Wl,-rpath,${CXX_PATH}/lib64 And: CFLAGS := -flto -ffat-lto-objects