https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78457

            Bug ID: 78457
           Summary: attempt to instantiate unused template
           Product: gcc
           Version: 6.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: barry.revzin at gmail dot com
  Target Milestone: ---

The following fails to compile on any version of gcc (or clang) I tried:

#include <iostream>

template <class... Ts> struct X;
template <class T> struct X<T> { };

template <class... Us> struct Y { X<Us...> x; };

template <class... Ts>
std::ostream& operator<<(std::ostream& os, Y<Ts...> const& ) {
  os << std::endl;
  return os;
}

int main()
{ }

with the error:

prog.cc: In instantiation of 'struct Y<>':
prog.cc:10:16:   required from here
prog.cc:6:44: error: 'Y<Us>::x' has incomplete type
 template <class... Us> struct Y { X<Us...> x; };
                                            ^
prog.cc:3:31: note: declaration of 'struct X<>'
 template <class... Ts> struct X;
                               ^

but no instance of Y is ever created, much less Y<> in operator<<. Moreover,
replacing std::endl with '\n' makes the code compile.

Reply via email to