[llvm-bugs] [Bug 46218] New: Concepts: cannot find matching function when requires clause contains invalid expression

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jun 5 13:58:45 PDT 2020


            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: unassignedclangbugs at nondot.org
          Reporter: maria.baburina at jetbrains.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

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;

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200605/1bf557c1/attachment.html>

More information about the llvm-bugs mailing list