https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115420
Bug ID: 115420 Summary: Default constructor of unordered_map deleted Product: gcc Version: 13.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: krebbel at gcc dot gnu.org Target Milestone: --- t.cc: #include <unordered_map> #include <condition_variable> class Foo { std::unordered_map<std::string, uint64_t> bar; Foo() : bar() {} }; g++ -std=c++11 -c t.cc fails with: t.cc: In constructor ‘Foo::Foo()’: t.cc:6:11: error: use of deleted function ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::__cxx11::basic_string<char>; _Tp = long unsigned int; _Hash = std::hash<std::__cxx11::basic_string<char> >; _Pred = std::equal_to<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]’ 6 | Foo() : bar() {} | ^~~~~ In file included from /home2/andreas/bisect/gcc-02dab998665-install/include/c++/13.0.0/unordered_map:41, from t.cc:1: /home2/andreas/bisect/gcc-02dab998665-install/include/c++/13.0.0/bits/unordered_map.h:146:7: note: ‘std::unordered_map<_Key, _Tp, _Hash, _Pred, _Alloc>::unordered_map() [with _Key = std::__cxx11::basic_string<char>; _Tp = long unsigned int; _Hash = std::hash<std::__cxx11::basic_string<char> >; _Pred = std::equal_to<std::__cxx11::basic_string<char> >; _Alloc = std::allocator<std::pair<const std::__cxx11::basic_string<char>, long unsigned int> >]’ is implicitly deleted because the default definition would be ill-formed: 146 | unordered_map() = default; | ^~~~~~~~~~~~~ starting with: commit 227351345d0caa596eff8325144f15b15f704c08 Author: Jonathan Wakely <jwak...@redhat.com> Date: Thu Jan 12 13:03:01 2023 +0000 libstdc++: Do not include <system_error> in concurrency headers The <condition_variable>, <mutex>, and <shared_mutex> headers use std::errc constants, but don't use std::system_error itself. They only use the __throw_system_error(int) function, which is defined in <bits/functexcept.h>. By including the header for the errc constants instead of the whole of <system_error> we avoid depending on the whole std::string definition. libstdc++-v3/ChangeLog: * include/bits/std_mutex.h: Remove <system_error> include. * include/std/condition_variable: Add <bits/error_constants.h> include. * include/std/mutex: Likewise. * include/std/shared_mutex: Likewise. The testcase works fine with gcc 12 and clang. There are similar BZs on that topic but these do not seem to fit exactly, as I understand it (e.g. 107022)