Issue 180131
Summary Clang rejects valid program saying implicit instantiation of undefined primary template
Labels clang
Assignees
Reporter ranaanoop
    The following program is rejected by clang but accepted by both gcc and msvc. [Demo](https://godbolt.org/z/KKe9jT8E3)

```
#include <type_traits>

template <class...>
struct fn_ref_call;

template <class R, class... Args>
struct fn_ref_call<R (Args...)> {
    static constexpr bool enable = true;
};

template <class... S>
struct fn_ref : private fn_ref_call<S...> {
private:
    using base = fn_ref_call<S...>;

public:
    template<class F>
        requires (base::enable)
    fn_ref(F* f){}
};

template<class F>
    requires std::is_function_v<F>
fn_ref(F *) -> fn_ref<F>;

int fn(int) { return 3; }


int main() {
    fn_ref f{&fn};
}
```
Clang says:
```
<source>:12:25: error: implicit instantiation of undefined template 'fn_ref_call<>'
   12 | struct fn_ref : private fn_ref_call<S...> {
      |                         ^
<source>:18:19: note: in instantiation of template class 'fn_ref<>' requested here
   18 |         requires (base::enable)
      |                   ^
<source>:18:19: note: while substituting template arguments into constraint _expression_ here
   18 | requires (base::enable)
      | ^~~~~~~~~~~~
<source>:30:12: note: while checking constraint satisfaction for template '<deduction guide for fn_ref><int (int)>' required here
   30 | fn_ref f{&fn};
      |            ^
<source>:30:12: note: while substituting deduced template arguments into function template '<deduction guide for fn_ref>' [with S = (no value), F = int (int)]
<source>:4:8: note: template is declared here
    4 | struct fn_ref_call;
```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to