https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106825
Bug ID: 106825 Summary: header unit <memory> based std::shared_ptr<...>(...) use gets: undefined reference to `std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M _release()', aarch64 example Product: gcc Version: 12.2.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: markmigm at gmail dot com Target Milestone: --- In, for example, aarch64 Fedora 36, with its g++ 12.2.1 related toolchain, the program: // c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -fPIC -xc++-system-header memory // c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -fPIC -omodule_shared_ptr_failure module_shared_ptr_failure.cpp import <memory>; struct base{int v=0;}; int main() { return std::shared_ptr<base>(new base{})->v; } gets the following failure for the shown command sequence: # c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -fPIC -xc++-system-header memory # c++ -std=c++20 -pedantic -Wall -Wextra -fmodules-ts -fPIC -omodule_shared_ptr_failure module_shared_ptr_failure.cpp /usr/bin/ld: /tmp/ccm2DaSN.o: in function `std::__shared_count<(__gnu_cxx::_Lock_policy)2>::~__shared_count()': module_shared_ptr_failure.cpp:(.text._ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EED2Ev[_ZNSt14__shared_countILN9__gnu_cxx12_Lock_policyE2EED5Ev]+0x24): undefined reference to `std::_Sp_counted_base<(__gnu_cxx::_Lock_policy)2>::_M_release()' collect2: error: ld returned 1 exit status The -fPIC use is not required to see the problem. For reference: # c++ -v Using built-in specs. COLLECT_GCC=c++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/aarch64-redhat-linux/12/lto-wrapper Target: aarch64-redhat-linux Configured with: ../configure --enable-bootstrap --enable-languages=c,c++,fortran,objc,obj-c++,ada,go,lto --prefix=/usr --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=http://bugzilla.redhat.com/bugzilla --enable-shared --enable-threads=posix --enable-checking=release --enable-multilib --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-gnu-unique-object --enable-linker-build-id --with-gcc-major-version-only --enable-libstdcxx-backtrace --with-linker-hash-style=gnu --enable-plugin --enable-initfini-array --with-isl=/builddir/build/BUILD/gcc-12.2.1-20220819/obj-aarch64-redhat-linux/isl-install --enable-gnu-indirect-function --build=aarch64-redhat-linux --with-build-config=bootstrap-lto --enable-link-serialization=1 Thread model: posix Supported LTO compression algorithms: zlib zstd gcc version 12.2.1 20220819 (Red Hat 12.2.1-1) (GCC)