[llvm-bugs] [Bug 49513] New: Invalid type in constraint substitution results in hard error instead of substitution failure

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Mar 10 07:01:56 PST 2021


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

            Bug ID: 49513
           Summary: Invalid type in constraint substitution results in
                    hard error instead of substitution failure
           Product: clang
           Version: 11.0
          Hardware: PC
                OS: Windows NT
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: barry.revzin at gmail.com
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

>From StackOverflow (https://stackoverflow.com/q/66562184/2069064):

template<class T>
struct A {
    constexpr bool operator()() requires T::value { return T::value; }
    constexpr bool operator()() { return false; }
};

static_assert(!A<void>()());

clang rejects this, saying:

<source>:3:42: error: type 'void' cannot be used prior to '::' because it has
no members
    constexpr bool operator()() requires T::value { return T::value; }
                                         ^
<source>:7:16: note: in instantiation of template class 'A<void>' requested
here
static_assert(!A<void>()());
               ^

But the rule in [temp.constr.atomic] is that "if substitution results in an
invalid type or expression, the constraint is not satisfied." Which is what
should happen here. gcc and msvc accept.

-- 
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/20210310/dedb3be0/attachment.html>


More information about the llvm-bugs mailing list