[EXTERNAL] Re: Linking issue when mixing GCC10/GCC11 artifacts

Oleg Smolsky osmolsky@netskope.com
Tue Jun 29 15:39:54 GMT 2021


I am using `g++` to link in both working and failing cases.

Oleg.

On Mon, Jun 28, 2021 at 10:32 PM Jonathan Wakely <jwakely.gcc@gmail.com>
wrote:

>
>
> On Tue, 29 Jun 2021, 05:58 Oleg Smolsky via Gcc-help, <
> gcc-help@gcc.gnu.org> wrote:
>
>> Hi, I've just hit a peculiar linking issue when using std::unordered_map,
>> C++17 and mixing some shared libs built with GCC10/11. Here is the linking
>> issue:
>>
>> test.o: In function `__gnu_cxx::new_allocator<std:
>> :__detail::_Hash_node_base*>::allocate(unsigned long, void const*)':
>> /opt/gcc-11/include/c++/11.1.0/ext/new_allocator.h:110: undefined
>> reference
>> to `std::__throw_bad_array_new_length()'
>> collect2: error: ld returned 1 exit status
>>
>> The reproducer looks benign to me:
>>
>> struct Thing { int a, b, c; };
>>  int main(int argc, char **argv) {
>>     std::unordered_map<unsigned int, Thing *> map;
>>     map[1] = new Thing;
>> }
>>
>> I hit the linking issue when the reproducer is built with GCC11 and I
>> link libzmq.so.3 that was built with GCC10. This is all happening on a
>> 64-bit Linux VM and I built both compilers on the same OS (Ubuntu 16). The
>> issue goes away when I rebuild the 3rd-party lib with GCC11... yet I am
>> failing to understand why this is happening... Is this an oversight in
>> libstdc++ that results in an ABI break?
>>
>
> Are you using 'gcc' to link, not 'g++'?
>
>
>


More information about the Gcc-help mailing list