[llvm-bugs] [Bug 44890] New: Clang fails to instantiate parent class with parameter pack

via llvm-bugs llvm-bugs at lists.llvm.org
Wed Feb 12 21:02:39 PST 2020


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

            Bug ID: 44890
           Summary: Clang fails to instantiate parent class with parameter
                    pack
           Product: clang
           Version: 10.0
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: Frontend
          Assignee: unassignedclangbugs at nondot.org
          Reporter: smeenai at fb.com
                CC: hans at chromium.org, llvm-bugs at lists.llvm.org,
                    neeilans at live.com, richard-llvm at metafoo.co.uk
            Blocks: 44555

$ cat reduced.cpp
template <class... Ts>
struct tuple {};

template <unsigned I, class... Ts>
int get0(const tuple<Ts...>& t) {
  return 0;
}

template <class... Ts>
struct tuple_wrapper : public tuple<Ts...> {
  template <unsigned I>
  int get() {
    return get0<0, Ts...>(*this);
  }
};

int f() {
  tuple_wrapper<int> w;
  return w.get<0>();
}

$ clang -cc1 -fsyntax-only reduced.cpp
reduced.cpp:13:12: error: no matching function for call to 'get0'
    return get0<0, Ts...>(*this);
           ^~~~~~~~~~~~~~
reduced.cpp:19:12: note: in instantiation of function template specialization
'tuple_wrapper<int>::get<0>' requested here
  return w.get<0>();
           ^
reduced.cpp:5:5: note: candidate template ignored: deduced type 'const tuple<>'
of 1st parameter does not match adjusted type 'tuple_wrapper<int>' of argument
[with I = 0, Ts = <>]
int get0(const tuple<Ts...>& t) {
    ^
1 error generated.

I bisected this to
https://github.com/llvm/llvm-project/commit/907cefe721437fa8950c1b6c1c028038b175f921,
so it's a regression in 10.0. gcc, MSVC and Clang 9 all accept this code:
https://godbolt.org/z/TfZBf2

Clang trunk does compile this if I explicitly instantiate the parent class, but
I don't believe that should be necessary, i.e. if I change the body of
tuple_wrapper::get to

    return get0<0, Ts...>(tuple<Ts...>(*this));


Referenced Bugs:

https://bugs.llvm.org/show_bug.cgi?id=44555
[Bug 44555] [meta] 10.0.0 Release Blockers
-- 
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/20200213/c6969138/attachment.html>


More information about the llvm-bugs mailing list