Skip to content

Bogus "constraint depends on itself" #134880

Open
@Boris-Rasin

Description

@Boris-Rasin
#include <concepts>

struct A
{
    template <typename X>
        requires requires (A a) { func1<X>(a); }
    operator X() const
    {
        return {};
    }
};

template <std::same_as<bool> T>
void func1(int) {}

template <std::same_as<bool> T>
void func1(A) {}

int main()
{
    A a;
    bool b = a;
    
    return 0;
}

Clang 20.1.0
-std=c++20

Compiler Explorer:
https://godbolt.org/z/or9eh7bax

This works with gcc and msvc, but fails with clang:

<source>:6:18: error: satisfaction of constraint 'requires (A a) { func1<X>(a); }' depends on itself

Instantiating func1<int>() fails, but clang still tries to match the function parameter, as if func1<int>(int) instantiated successfully.

Metadata

Metadata

Assignees

No one assigned

    Labels

    clang:frontendLanguage frontend issues, e.g. anything involving "Sema"conceptsC++20 conceptsdiverges-from:gccDoes the clang frontend diverge from gcc on this issuediverges-from:msvcDoes the clang frontend diverge from msvc on this issue

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions