[llvm-bugs] [Bug 44657] New: Rejects valid code with requires clause accepting bool expression on copy / move

via llvm-bugs llvm-bugs at lists.llvm.org
Fri Jan 24 19:44:58 PST 2020


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

            Bug ID: 44657
           Summary: Rejects valid code with requires clause accepting bool
                    expression on copy / move
           Product: clang
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: C++2a
          Assignee: unassignedclangbugs at nondot.org
          Reporter: david at doublewise.net
                CC: blitzrakete at gmail.com, erik.pilkington at gmail.com,
                    llvm-bugs at lists.llvm.org, richard-llvm at metafoo.co.uk

The following code

```
template<typename>
constexpr bool true_ = true;

template<typename Ts>
struct s {
        s(int)
        {
        }


        s(s const &) requires(true_<Ts>) {}
};

auto v = s<int>(5);
```

Outputs

```
main.cpp:11:24: error: substitution into constraint expression resulted in a
non-constant expression
        s(s const &) requires(true_<Ts>) {}
                              ^~~~~~~~~
main.cpp:11:24: note: subexpression not valid in a constant expression
1 error generated.
```

When compiled with `clang++ -std=c++2a -o /dev/null -c main.cpp`

The error goes away if I define `true_` as a concept rather than a bool. This
seems to apply only to copy / move constructors / assignment operators.

-- 
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/20200125/bcf98750/attachment.html>


More information about the llvm-bugs mailing list