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

<functional>: boyer_moore_searcher and boyer_moore_horspool_searcher should accept ADL-incompatible element types #4380

Open
frederick-vs-ja opened this issue Feb 9, 2024 · 1 comment
Labels
bug Something isn't working

Comments

@frederick-vs-ja
Copy link
Contributor

frederick-vs-ja commented Feb 9, 2024

Describe the bug

The following program doesn't compile with MSVC STL due to ADL which attempts to complete a bad type.

#include <algorithm>
#include <functional>

template <class T>
struct holder {
    T t;
};

struct incomplete;

int main() {
    using validator = holder<incomplete>*;
    validator varr[1]{};
    (void) std::search(varr, varr + 1, std::boyer_moore_searcher<const validator*>{varr, varr + 1});
    (void) std::search(varr, varr + 1, std::boyer_moore_horspool_searcher<const validator*>{varr, varr + 1});
}

After the changes in #4379, the bug of MSVC STL comes from allocator comparison and iterator operations in unordered_map which is internally used by both searchers.

unordered_map<_Value_t, _Diff, _Hash_ty, _Pred_eq> _Map;

Command-line test case

Godbolt link.

Other standard library implementations seem to be buggy due to similar reasons.

Expected behavior

This example compiles.

STL version

Microsoft Visual Studio Community 2022
Version 17.9.0 Preview 5.0

Additional context

_STD-qualification doesn't work for this case. We may need to change the type of the unordered_map to avoid undesired ADL, which may be dangerous for ABI-compatibility.

@StephanTLavavej
Copy link
Member

We talked about this at the weekly maintainer meeting and while this may technically be a bug, it's super low priority and basically everything else is more important to spend reviewer time on. We'd be fine with this being broken forever, barring an example of a reasonable program that needs this. (The vast majority of Boyer-Moore searches will be using plain old character types, nothing exotic.)

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

No branches or pull requests

3 participants