https://bugs.llvm.org/show_bug.cgi?id=46218

            Bug ID: 46218
           Summary: Concepts: cannot find matching function when requires
                    clause contains invalid expression
           Product: clang
           Version: trunk
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

Clang cannot find matching function constrained on a concept when its requires
clause has invalid expression but would otherwise evaluate to true. Code
compiles correctly with MSVC 19.27.28826.0 and GCC 10.1 but not Clang 10. 

>From https://en.cppreference.com/w/cpp/language/constraints:

The substitution of template arguments into a requires-expression used in a
declaration of a templated entity may result in the formation of invalid types
or expressions in its requirements, or the violation of semantic constraints of
those requirements. In such cases, the requires-expression evaluates to false
and does not cause the program to be ill-formed. The substitution and semantic
constraint checking proceeds in lexical order and stops when a condition that
determines the result of the requires-expression is encountered. If
substitution (if any) and semantic constraint checking succeed, the
requires-expression evaluates to true. 


#include <concepts>

struct S {
    double value;
};

template <class T>
concept fp_or_value = requires (T x) {
   requires std::floating_point<decltype(x.value)> || std::floating_point<T>;
};

template <fp_or_value T>
void test(T x) {}

int main() {
    double x = 1.0;
    test(x);
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to