[llvm-bugs] [Bug 44670] New: Rejects valid code with requires clause referring to function parameter when called from variadic function
via llvm-bugs
llvm-bugs at lists.llvm.org
Sun Jan 26 10:24:37 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44670
Bug ID: 44670
Summary: Rejects valid code with requires clause referring to
function parameter when called from variadic function
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
```
struct s {};
constexpr bool f(s) {
return true;
}
template<typename T>
bool a(T t) requires(f(t)) {
return true;
}
template<typename... Args>
bool b(Args ... args) {
(..., a(args));
return true;
}
//bool x = a(s());
bool y = b(s());
```
when compiled against 8d6884a15e86419c51ba456f8b6f5223696800a1 with the command
`clang++ -std=c++2a -o /dev/null -c main.cpp` should compile with no errors.
Instead, it outputs
```
main.cpp:14:8: error: no matching function for call to 'a'
(..., a(args));
^
main.cpp:19:10: note: in instantiation of function template specialization
'b<s>' requested here
bool y = b(s());
^
main.cpp:8:6: note: candidate function not viable: constraints not satisfied
bool a(T t) requires(f(t)) {
^
main.cpp:8:24: note: because substituted constraint expression is ill-formed:
reference to local variable 't' declared in enclosing function 'a<s>'
bool a(T t) requires(f(t)) {
^
1 error generated.
```
Uncommenting the direct call to `a` (the variable `x`) causes clang to accept
the code.
--
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/20200126/e7a98c7a/attachment-0001.html>
More information about the llvm-bugs
mailing list