Skip to content

Concepts 'more constrained' not detected for member functions #56154

Closed
@royjacobson

Description

@royjacobson

https://godbolt.org/z/bvKGhY4Yz

template <int N> concept C0 = (N == 0);
template <int N, int N2> concept C0x = C0<N>;
template <int N1, int N2> concept C00 = C0x<N1, N2> && C0<N2>;

template<int N1, int N2>
struct A {
    void f() requires C00<N1, N2>;
    void f() requires C0x<N1, N2>;
};

template<int N1, int N2>
void f() requires C00<N1, N2>;

template<int N1, int N2>
void f() requires C0x<N1, N2>;

int main() {
    f<0, 0>(); // Works

    A<0, 0> a;
    a.f();  // Works in GCC only.
}

This should compile, I think, but it doesn't. For some reason MSVC also say that a.f() is ambiguous.

Metadata

Metadata

Assignees

Labels

clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsrejects-valid

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions