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

            Bug ID: 89477
           Summary: Incorrect CTAD deduction guides for set and multiset
           Product: gcc
           Version: unknown
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: arthur.j.odwyer at gmail dot com
  Target Milestone: ---

I just implemented set/multiset deduction guides for libc++ because they were
missing entirely. My regression test fails on libstdc++ trunk.
The full test is here (non-GNU code warning!) https://reviews.llvm.org/D58582
and https://godbolt.org/z/4-OFMh

The reduced test case is:

```
// https://godbolt.org/z/0TNJ59
#include <set>
#include <memory_resource>

int main()
{
    std::pmr::polymorphic_allocator<int> a;
    int arr[] = {1,2,3};
    std::set s(arr, arr+3, a);  // ERROR

    std::set t({1, 2, 3}, a);  // ERROR 
}
```

libstdc++ believes that CTAD is ambiguous here because although it is obvious
that "arr" and "arr+3" are InputIterators, it is not sure whether
"std::pmr::polymorphic_allocator<int>()" is intended to be an Allocator or a
Compare.

http://eel.is/c++draft/container.requirements#associative.reqmts-15.3
is clear that a deduction guide template parameter named Compare should not
pick up anything which "qualifies as an allocator." So this CTAD should be
unambiguous.

Reply via email to