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

error_code hash bug in tests #277

Open
seanbaxter opened this issue Feb 1, 2022 · 0 comments
Open

error_code hash bug in tests #277

seanbaxter opened this issue Feb 1, 2022 · 0 comments

Comments

@seanbaxter
Copy link
Contributor

https://github.com/bloomberg/bde/blob/master/groups/bsl/bslstl/bslstl_error.t.cpp#L1359

There's no guarantee that the std::hash of an std::error_code differ if the error code categories are different. Indeed, on libc++, this is the case:

template <>
struct _LIBCPP_TEMPLATE_VIS hash<error_code>
    : public unary_function<error_code, size_t>
{
    _LIBCPP_INLINE_VISIBILITY
    size_t operator()(const error_code& __ec) const _NOEXCEPT
    {
        return static_cast<size_t>(__ec.value());
    }
};

It only hashes the value, not the category.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant