[llvm-bugs] [Bug 45589] New: Short-circuiting in a requires-clause stops working if any overload of `&&`/`||` is visible

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Apr 17 12:46:52 PDT 2020


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

            Bug ID: 45589
           Summary: Short-circuiting in a requires-clause stops working if
                    any overload of `&&`/`||` is visible
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: blckcat at inbox.ru
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

Short-circuiting in a requires-clause normally works, but if any overload of
`&&`/`||` is visible, the corresponding operator stops short-circuiting.

Example for `||`:

struct Dummy {};
// Uncommenting this breaks the code:
// bool operator||(Dummy, Dummy) {return true;}

template <typename T>
struct A
{
    static constexpr bool value = T::value;
};

template <typename T>
void foo() requires (sizeof(T) == 1) || A<T>::value {}

int main()
{
    foo<char>();
}

-- 
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/20200417/0fcd3870/attachment.html>


More information about the llvm-bugs mailing list