https://gcc.gnu.org/bugzilla/show_bug.cgi?id=115854

            Bug ID: 115854
           Summary: Copy-initialization or implicit conversion is used
                    when creating an allocator whose type is obtained by
                    rebind
           Product: gcc
           Version: 14.1.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: zwuis at outlook dot com
  Target Milestone: ---

Code:
```cpp
// g++ -std=c++20 test.cpp
#include <cstdlib>
#include <vector>

template <typename T>
class Allocator {
  public:
    using value_type = T;

    Allocator() = default;

    template <typename U>
    explicit Allocator(const Allocator<U> &) noexcept {
    }

    T *allocate(std::size_t n) {
        return (T *)malloc(n * sizeof(T));
    }

    void deallocate(T *p, std::size_t n) {
        free(p);
    }
};

int main() {
    std::vector<bool, Allocator<bool>> vec(Allocator<bool> {});
}
```

Godbolt: https://godbolt.org/z/EGr8rs8hv

Cppreference: https://en.cppreference.com/w/cpp/named_req/Allocator
Standard draft:
https://eel.is/c++draft/allocator.requirements.general#itemdecl:26

Direct-initialization is only required.

Reply via email to