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: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

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.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to