https://sourceware.org/bugzilla/show_bug.cgi?id=26347
Bug ID: 26347 Summary: Partial initialization of std::cout on linkage with `-static-libstdc++` and other dynamic library Product: binutils Version: 2.34 Status: UNCONFIRMED Severity: normal Priority: P2 Component: gold Assignee: ccoutant at gmail dot com Reporter: demansong at gmail dot com CC: ian at airs dot com Target Milestone: --- Dynamic library which I link with my application also incudes <iostream> but it wasn't linked with static lib stdc++. The problem goes away when I switch linker from gold to bfd. Here is the minimal sample: $ echo '#include <iostream>' >2.cpp $ g++ 2.cpp -shared -o 2.so $ echo '#include <iostream>' >1.cpp $ echo 'int main() { std::cout << 42 << std::endl; }' >>1.cpp $ g++ 1.cpp -static-libstdc++ -fuse-ld=gold -o 1 $ LD_PRELOAD=./2.so ./1 $ g++ 1.cpp -static-libstdc++ -o 1 $ LD_PRELOAD=./2.so ./1 42 I found out that `this->_M_num_put` in std::cout is nullptr when application is linked with gold so ios_base::Init::Init() in my app works probably erroneously. I tested it with binutils 2.34 (ubuntu 20.04) and binutils 2.30 (a toolchain built with crosstool-ng). GCC versions was 7.5.0, 8.1.0, 8.4.0, 9.3.0 and 10.1.0. -- You are receiving this mail because: You are on the CC list for the bug.