Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

<xstring>: Restrict enabled hash specializations as required by the standard #2741

Merged
merged 10 commits into from
Jun 2, 2022

Conversation

frederick-vs-ja
Copy link
Contributor

Fixes #757. Perhaps libcxx tests are enough.

I also move _Is_EcharT to <xstring> because I think its usage may be more general.

@frederick-vs-ja frederick-vs-ja requested a review from a team as a code owner May 26, 2022 06:11
@fsb4000
Copy link
Contributor

fsb4000 commented May 26, 2022

failed tests/Dev09_172666_tr1_tuple_odr

Same thing. I ran into the issue yesterday: #2739 (comment)

template <class>
_INLINE_VAR constexpr bool _Is_EcharT = false;
template <>
_INLINE_VAR constexpr bool _Is_EcharT<char> = true;

in two different cpp files gives fatal error LNK1169: one or more multiply defined symbols found with clang-cl and C++14.
because _INLINE_VAR is nothing in C++14.

I think you can use _Is_any_of_v too

Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree the existing test coverage suffices.

stl/inc/xstring Outdated Show resolved Hide resolved
stl/inc/xstring Outdated Show resolved Hide resolved
@CaseyCarter CaseyCarter added the bug Something isn't working label May 26, 2022
Only specialize on char_traits<_Elem>
@StephanTLavavej StephanTLavavej self-assigned this Jun 1, 2022
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@StephanTLavavej
Copy link
Member

This breaks the compiler backend with:

   643>D:\msvc\binaries\x86chk\inc\unordered_map(50,99): error C2280: 'std::_Uhash_compare<_Kty,_Hasher,_Keyeq>::_Uhash_compare(const std::_Uhash_compare<_Kty,_Hasher,_Keyeq> &)': attempting to reference a deleted function [D:\msvc\src\vctools\Compiler\Utc\build\arm64\utc-arm64.nativeproj]
                 with
                 [
                     _Kty=std::basic_string<char,std::char_traits<char>,UtcPoolAllocator<T_ALLOC,char>>,
                     _Hasher=std::hash<std::basic_string<char,std::char_traits<char>,UtcPoolAllocator<T_ALLOC,char>>>,
                     _Keyeq=std::equal_to<void>
                 ]
             explicit _Umap_traits(const _Tr& _Traits) noexcept(is_nothrow_copy_constructible_v<_Tr>) : _Tr(_Traits) {}
                                                                                                           ^

This isn't necessarily blocking (we could change the backend to use a custom hash), but it indicates that this change will be highly breaking.

I think we should speculatively implement LWG-3705 "Hashability shouldn't depend on basic_string's allocator" here, now that @CaseyCarter's newly filed issue has a number. I'll validate and push changes to avoid having to drop this from the mirror PR.

@StephanTLavavej StephanTLavavej merged commit d8d8a6b into microsoft:main Jun 2, 2022
@StephanTLavavej
Copy link
Member

Thanks for improving conformance here and fixing these libcxx skips! 🎉 😻 ✅

@frederick-vs-ja frederick-vs-ja deleted the restrict-string-hash branch June 2, 2022 01:27
Copy link
Member

@CaseyCarter CaseyCarter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For posterity: this is my late approval of STL's final changes, which are exactly how I'd planned to implement LWG-3705.

fsb4000 pushed a commit to fsb4000/STL that referenced this pull request Aug 13, 2022
…he standard (microsoft#2741)

Co-authored-by: Stephan T. Lavavej <stl@nuwen.net>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

<xstring>: Too many enabled hash specializations
4 participants
  翻译: