public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/115420] New: Default constructor of unordered_map deleted
@ 2024-06-10 17:20 krebbel at gcc dot gnu.org
  2024-06-10 17:23 ` [Bug libstdc++/115420] " pinskia at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: krebbel at gcc dot gnu.org @ 2024-06-10 17:20 UTC (permalink / raw)
  To: gcc-bugs

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 <jwakely@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)

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2024-06-25 10:59 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-10 17:20 [Bug c++/115420] New: Default constructor of unordered_map deleted krebbel at gcc dot gnu.org
2024-06-10 17:23 ` [Bug libstdc++/115420] " pinskia at gcc dot gnu.org
2024-06-11  5:46 ` krebbel at gcc dot gnu.org
2024-06-11  5:47 ` krebbel at gcc dot gnu.org
2024-06-11  7:08 ` xry111 at gcc dot gnu.org
2024-06-11  9:41 ` redi at gcc dot gnu.org
2024-06-11  9:44 ` redi at gcc dot gnu.org
2024-06-11  9:55 ` redi at gcc dot gnu.org
2024-06-13 13:10 ` cvs-commit at gcc dot gnu.org
2024-06-13 13:14 ` redi at gcc dot gnu.org
2024-06-25 10:59 ` redi at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).