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

            Bug ID: 78754
           Summary: incorrectly accepts non-deductible template parameter
                    pack in function template
           Product: gcc
           Version: 6.2.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: felix.morgner at gmail dot com
  Target Milestone: ---

g++ incorrectly accepts the following code that contains a non-deductible
template parameter pack:

  #include <utility>

  template<std::size_t ...Ns, typename ...Ts>
  void foo(std::index_sequence<Ns...>)
    {
    }

  int main()
    {
    foo(std::make_index_sequence<5>{});
    }

ISO14882:2014 states the following in [temp.param]:

(9) [...] A default template-argument may be specified for any kind of
template-parameter (type, non-type, template) that is not a template parameter
pack (14.5.3). [...]

(11) [...]  A template parameter pack of a function template shall not be
followed by another template parameter unless that template parameter can be
deduced from the parameter-type-list of the function template or has a default
argument (14.8.2).

It also gives an example similar to the above. As far as I can tell, it is
neither possible to deduce nor to specify the types for 'Ts' and thus this
template function should be rejected.

The example code was compiled with the following command line invocation:

  g++ -Wall -Wextra -pedantic -pedantic-errors -Werror -std=c++14 templ.cpp

Reply via email to