<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/61007>61007</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
std::default_initializable in libc++ accepts an std::unordered_set of a type with no hash
</td>
</tr>
<tr>
<th>Labels</th>
<td>
new issue
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
captaincrutches
</td>
</tr>
</table>
<pre>
Godbolt: https://clang.godbolt.org/z/aqahhrdvK
Code to reproduce:
```cpp
#include <concepts>
#include <unordered_set>
struct foo {};
static_assert(!std::default_initializable<std::unordered_set<foo>>);
```
This compiles correctly in gcc as far back as 10, and indeed clang also accepts it when using `libstdc++` as far back as clang-13.
When using libc++ however, it fails (on clang 13, 14, 15, and trunk):
```
<source>:6:1: error: static assertion failed due to requirement '!std::default_initializable<std::unordered_set<foo, std::hash<foo>, std::equal_to<foo>, std::allocator<foo>>>'
static_assert(!std::default_initializable<std::unordered_set<foo>>);
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.
Compiler returned: 1
```
Each component of `default_initializable` (`constructible_from` and a default constructor itself) also pass the `static_assert`. But in all cases, clang does correctly fail to actually construct an `std::unordered_set<foo>`.
It does correctly conclude that `std::default_initializable<std::hash<foo>>` is false.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJy8VUFv8zYM_TXKhWhgy4mdHHxI02YYdh2wY0FLdKx9iuRKVIt-h_32QXbaJEXRARuwwHCUUOIj-R4pjNEcHVEr1vdi_bDAxIMPrcKR0TgVEquB4qLz-q39xevOWxbVDgbmMYpqJ-RByIOy6I7L42xe-nAU8vBTyAM-4zAE_fKbKB5EsZvfe68J2EOgMXidFGU3s70u5keN4_kfWRmnbNIEotor7xSNHEX1-JU5OR80BdJPkfiyZ3pHDkkx9N6DaO5F8yCq-1s7slFPGCMFFnIjZBlZ58iqnaY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