Bug 96218 - DR 2032: Default template-arguments of variable templates
Summary: DR 2032: Default template-arguments of variable templates
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: unknown
: P3 normal
Target Milestone: ---
Assignee: Marek Polacek
URL:
Keywords: accepts-invalid
Depends on:
Blocks: c++-core-issues
  Show dependency treegraph
 
Reported: 2020-07-16 12:28 UTC by Marek Polacek
Modified: 2020-08-03 21:45 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2020-07-16 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Marek Polacek 2020-07-16 12:28:22 UTC
// DR 2032 - Default template-arguments of variable templates

// [temp.param]/14: If a template-parameter of a class template, variable
// template, or alias template has a default template-argument, each subsequent
// template-parameter shall either have a default template-argument supplied or
// be a template parameter pack.
template<typename T = int, typename U> // error
T vt;

// [temp.param]/14: If a template-parameter of a primary class template,
// primary variable template, or alias template is a template parameter pack,
// it shall be the last template-parameter.
template<typename... Ts, typename U> // error
int vt2;

Here we should give two errors under DR 2032, but we only give the first one.
Comment 1 GCC Commits 2020-08-03 21:43:37 UTC
The master branch has been updated by Marek Polacek <mpolacek@gcc.gnu.org>:

https://gcc.gnu.org/g:50bee766bc9f4020cf1f814178155d16e80dccaa

commit r11-2521-g50bee766bc9f4020cf1f814178155d16e80dccaa
Author: Marek Polacek <polacek@redhat.com>
Date:   Thu Jul 16 09:15:37 2020 -0400

    c++: Variable template and template parameter pack [PR96218]
    
    This is DR 2032 which says that the restrictions regarding template
    parameter packs and default arguments apply to variable templates as
    well, but we weren't detecting that.
    
    gcc/cp/ChangeLog:
    
            DR 2032
            PR c++/96218
            * pt.c (check_default_tmpl_args): Also consider variable
            templates.
    
    gcc/testsuite/ChangeLog:
    
            DR 2032
            PR c++/96218
            * g++.dg/cpp1y/var-templ67.C: New test.
Comment 2 Marek Polacek 2020-08-03 21:45:34 UTC
Fixed.