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

            Bug ID: 105111
           Summary: Ambiguous constructor overload with requires
                    constraint
           Product: gcc
           Version: 12.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: andrei.popa105 at yahoo dot com
  Target Milestone: ---

Let's consider the following code:

#include <iostream>
#include <type_traits>

struct S {
    template <typename T> explicit S(T) noexcept requires
std::is_signed<T>::value {
        std::cout << "T\n";
    }
    template<typename T> explicit S(const T&) noexcept {
        std::cout << "const T&\n";
    }
};

int main() {
    S s(4);
}

To compile this code I used the following command and I provide also a link to
a godbolt instance:

g++ -std=c++23 example.cpp -o example

https://godbolt.org/z/vaGafvKcT

This code doesn't compile with gcc 12.0.
I think this is a bug because the most constrained constructor is the first one
and has a matching requires clause when we create the s object.

Reply via email to