skeeto / w64devkit

Portable C and C++ Development Kit for x64 (and x86) Windows
The Unlicense
2.66k stars 185 forks source link

<unordered_set> library doesn't compile #111

Closed Checkmate6659 closed 4 months ago

Checkmate6659 commented 4 months ago

for some reason when i try including and try creating one, i get loads of errors im compiling with g++ -O3 -flto -s -DNDEBUG *.cpp

here are the errors:


main.cpp:93:33: error: use of deleted function 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::vector<unsigned char>; _Hash = std::hash<std::vector<unsigned char> >; _Pred = std::equal_to<std::vector<unsigned char> >; _Alloc = std::allocator<std::vector<unsigned char> >]'
   93 |     unordered_set<vector<Face>> G;
      |                                 ^
In file included from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/unordered_set:41,
                 from main.cpp:3:
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/unordered_set.h:142:7: note: 'std::unordered_set<_Value, _Hash, _Pred, _Alloc>::unordered_set() [with _Value = std::vector<unsigned char>; _Hash = std::hash<std::vector<unsigned char> >; _Pred = std::equal_to<std::vector<unsigned char> >; _Alloc = std::allocator<std::vector<unsigned char> >]' is implicitly deleted because the default definition would be ill-formed:
  142 |       unordered_set() = default;
      |       ^~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/unordered_set.h:142:7: error: use of deleted function 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::vector<unsigned char>; _Value = std::vector<unsigned char>; _Alloc = std::allocator<std::vector<unsigned char> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<unsigned char> >; _Hash = std::hash<std::vector<unsigned char> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]'
In file included from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/unordered_set.h:33:
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:530:7: note: 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::_Hashtable() [with _Key = std::vector<unsigned char>; _Value = std::vector<unsigned char>; _Alloc = std::allocator<std::vector<unsigned char> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<unsigned char> >; _Hash = std::hash<std::vector<unsigned char> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed:
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:530:7: error: use of deleted function 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::vector<unsigned char>; _Value = std::vector<unsigned char>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<unsigned char> >; _Hash = std::hash<std::vector<unsigned char> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]'
In file included from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:35:
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1710:7: note: 'std::__detail::_Hashtable_base<_Key, _Value, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _Traits>::_Hashtable_base() [with _Key = std::vector<unsigned char>; _Value = std::vector<unsigned char>; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<unsigned char> >; _Hash = std::hash<std::vector<unsigned char> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _Traits = std::__detail::_Hashtable_traits<true, true, true>]' is implicitly deleted because the default definition would be ill-formed:
 1710 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1710:7: error: use of deleted function 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::vector<unsigned char>; _Value = std::vector<unsigned char>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::vector<unsigned char> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]'
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h: In instantiation of 'std::__detail::_Hashtable_ebo_helper<_Nm, _Tp, true>::_Hashtable_ebo_helper() [with int _Nm = 1; _Tp = std::hash<std::vector<unsigned char> >]':
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1297:7:   required from here
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1214:49: error: use of deleted function 'std::hash<std::vector<unsigned char> >::hash()'
 1214 |       _Hashtable_ebo_helper() noexcept(noexcept(_Tp())) : _Tp() { }
      |                                                 ^~~~~
In file included from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/string_view:42,
                 from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/basic_string.h:47,
                 from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/string:54,
                 from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/locale_classes.h:40,
                 from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/ios_base.h:41,
                 from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/ios:44,
                 from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/ostream:40,
                 from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/iostream:41,
                 from main.cpp:1:
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<unsigned char> >::hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:102:12: error: no matching function for call to 'std::__hash_enum<std::vector<unsigned char>, false>::__hash_enum()'
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:83:7: note: candidate: 'std::__hash_enum<_Tp, <anonymous> >::__hash_enum(std::__hash_enum<_Tp, <anonymous> >&&) [with _Tp = std::vector<unsigned char>; bool <anonymous> = false]'
   83 |       __hash_enum(__hash_enum&&);
      |       ^~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:83:7: note:   candidate expects 1 argument, 0 provided
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<unsigned char>; bool <anonymous> = false]' is private within this context
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:84:7: note: declared private here
   84 |       ~__hash_enum();
      |       ^
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1297:7: note: 'std::__detail::_Hash_code_base<_Key, _Value, _ExtractKey, _Hash, _RangeHash, _Unused, __cache_hash_code>::_Hash_code_base() [with _Key = std::vector<unsigned char>; _Value = std::vector<unsigned char>; _ExtractKey = std::__detail::_Identity; _Hash = std::hash<std::vector<unsigned char> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; bool __cache_hash_code = true]' is implicitly deleted because the default definition would be ill-formed:
 1297 |       _Hash_code_base() = default;
      |       ^~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1297:7: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<unsigned char> >, true>::~_Hashtable_ebo_helper()'
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1211:12: note: 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<unsigned char> >, true>::~_Hashtable_ebo_helper()' is implicitly deleted because the default definition would be ill-formed:
 1211 |     struct _Hashtable_ebo_helper<_Nm, _Tp, true>
      |            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1211:12: error: use of deleted function 'std::hash<std::vector<unsigned char> >::~hash()'
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:102:12: note: 'std::hash<std::vector<unsigned char> >::~hash()' is implicitly deleted because the default definition would be ill-formed:
  102 |     struct hash : __hash_enum<_Tp>
      |            ^~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:102:12: error: 'std::__hash_enum<_Tp, <anonymous> >::~__hash_enum() [with _Tp = std::vector<unsigned char>; bool <anonymous> = false]' is private within this context
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/functional_hash.h:84:7: note: declared private here
   84 |       ~__hash_enum();
      |       ^
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1710:7: error: use of deleted function 'std::__detail::_Hash_code_base<std::vector<unsigned char>, std::vector<unsigned char>, std::__detail::_Identity, std::hash<std::vector<unsigned char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
 1710 |       _Hashtable_base() = default;
      |       ^~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1275:12: note: 'std::__detail::_Hash_code_base<std::vector<unsigned char>, std::vector<unsigned char>, std::__detail::_Identity, std::hash<std::vector<unsigned char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()' is implicitly deleted because the default definition would be ill-formed:
 1275 |     struct _Hash_code_base
      |            ^~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1275:12: error: use of deleted function 'std::__detail::_Hashtable_ebo_helper<1, std::hash<std::vector<unsigned char> >, true>::~_Hashtable_ebo_helper()'
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:530:7: error: use of deleted function 'std::__detail::_Hashtable_base<std::vector<unsigned char>, std::vector<unsigned char>, std::__detail::_Identity, std::equal_to<std::vector<unsigned char> >, std::hash<std::vector<unsigned char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable_base()'
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1667:12: note: 'std::__detail::_Hashtable_base<std::vector<unsigned char>, std::vector<unsigned char>, std::__detail::_Identity, std::equal_to<std::vector<unsigned char> >, std::hash<std::vector<unsigned char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable_base()' is implicitly deleted because the default definition would be ill-formed:
 1667 |     struct _Hashtable_base
      |            ^~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable_policy.h:1667:12: error: use of deleted function 'std::__detail::_Hash_code_base<std::vector<unsigned char>, std::vector<unsigned char>, std::__detail::_Identity, std::hash<std::vector<unsigned char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, true>::~_Hash_code_base()'
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:530:7: error: use of deleted function 'constexpr std::_Enable_default_constructor<false, _Tag>::_Enable_default_constructor() [with _Tag = std::__detail::_Hash_node_base]'
  530 |       _Hashtable() = default;
      |       ^~~~~~~~~~
In file included from D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:36:
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/enable_special_members.h:113:15: note: declared here
  113 |     constexpr _Enable_default_constructor() noexcept = delete;
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h: In instantiation of 'std::_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _Hash, _RangeHash, _Unused, _RehashPolicy, _Traits>::~_Hashtable() [with _Key = std::vector<unsigned char>; _Value = std::vector<unsigned char>; _Alloc = std::allocator<std::vector<unsigned char> >; _ExtractKey = std::__detail::_Identity; _Equal = std::equal_to<std::vector<unsigned char> >; _Hash = std::hash<std::vector<unsigned char> >; _RangeHash = std::__detail::_Mod_range_hashing; _Unused = std::__detail::_Default_ranged_hash; _RehashPolicy = std::__detail::_Prime_rehash_policy; _Traits = std::__detail::_Hashtable_traits<true, true, true>]':
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/unordered_set.h:104:11:   required from here
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:1595:5: error: use of deleted function 'std::__detail::_Hashtable_base<std::vector<unsigned char>, std::vector<unsigned char>, std::__detail::_Identity, std::equal_to<std::vector<unsigned char> >, std::hash<std::vector<unsigned char> >, std::__detail::_Mod_range_hashing, std::__detail::_Default_ranged_hash, std::__detail::_Hashtable_traits<true, true, true> >::~_Hashtable_base()'
 1595 |     }
      |     ^
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:1587:21: error: static assertion failed: Cache the hash code or qualify your functors involved in hash code and bucket index computation with noexcept
 1587 |       static_assert(noexcept(declval<const __hash_code_base_access&>()
      |                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1588 |                         ._M_bucket_index(declval<const __node_value_type&>(),
      |                         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
 1589 |                                          (std::size_t)0)),
      |                                          ~~~~~~~~~~~~~~~~
D:/good_c_compiler/w64devkit/lib/gcc/x86_64-w64-mingw32/13.2.0/include/c++/bits/hashtable.h:1587:21: note: 'false' evaluates to false```
skeeto commented 4 months ago

Looks like a typical C++ template error. In this case it seems you haven't defined a hash function for std::vector. See here:

https://stackoverflow.com/questions/29855908/c-unordered-set-of-vectors

If you've done so, or if this program otherwise compiles under other C++ compilers, I'm interested in seeing a minimal program that reproduces the error.

Checkmate6659 commented 4 months ago

thanks it worked