[Bug libstdc++/126949] New: [15/16/17 Regression] Can't construct an unordered set with a hasher whose ctor is explicit

"gnu.ojxq8 at dralias dot com via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126949

            Bug ID: 126949
           Summary: [15/16/17 Regression] Can't construct an unordered set
                    with a hasher whose ctor is explicit
           Product: gcc
           Version: 17.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: gnu.ojxq8 at dralias dot com
  Target Milestone: ---

libstdc++15 and 16 do not allow to construct an unordered set with a
hasher whose ctor is explicit.

This is an issue with Clang, or with GCC -Wsystem-headers. See
https://godbolt.org/z/EGzKbjh84

Code:

```
// { dg-do compile { target c++11 } }
#include <unordered_set>
struct Hash {
    explicit Hash(bool = false) {}
    std::size_t operator()(int value) const { return value; }
};
int main() { std::unordered_set<int, Hash> set; }
```

error:

/opt/compiler-explorer/gcc-15.2.0/lib/gcc/x86_64-linux-gnu/15.2.0/../../../../include/c++/15.2.0/bits/hashtable_policy.h:1056:70:
error: chosen constructor is explicit in copy-initialization
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.