Bug 51666 - NSDMI parse fails for template'd intializer
Summary: NSDMI parse fails for template'd intializer
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: c++ (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Jason Merrill
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-23 14:15 UTC by miles
Modified: 2012-01-03 16:40 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2012-01-02 00:00:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description miles 2011-12-23 14:15:32 UTC
The following code:

   template<typename T, typename U>
   struct tuple
   {
     tuple(T, U) { }
   };

   struct Y
   {
     tuple<int, int> tt = tuple<int, int>{1, 2};   // *error*
   };

Fails with a parse error in gcc 4.7 20111210:

   $ g++-snapshot -c -std=c++11 nsdmi3.cc
   nsdmi3.cc:9:36: error: expected unqualified-id before 'int'
   nsdmi3.cc:9:31: error: wrong number of template arguments (1, should be 2)
   nsdmi3.cc:2:9: error: provided for 'template<class T, class U> struct tuple'

   $ g++-snapshot --version
   g++ (Debian 20111210-1) 4.7.0 20111210 (experimental) [trunk revision 182188]

Thanks,

-miles
Comment 1 Andrew Pinski 2011-12-30 06:30:47 UTC
I bet a beer this is related to PR 57 (one of the most duplicated bugs in bugzilla).  In fact the same work around fixes this testcase.  
Jason can you comment if DR 325 applies to NSDMI and not just default arguments?
Comment 2 Jonathan Wakely 2011-12-30 12:36:56 UTC
Ah yes, the latest note on DR 325 confirms the same issue exists with NSDMIs

http://open-std.org/JTC1/SC22/WG21/docs/cwg_active.html#325
Comment 3 Jason Merrill 2012-01-02 17:53:23 UTC
Author: jason
Date: Mon Jan  2 17:53:16 2012
New Revision: 182809

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=182809
Log:
	DR 325
	PR c++/51666
	* parser.c (cp_parser_cache_defarg): Split out...
	(cp_parser_parameter_declaration): ...from here.
	(cp_parser_save_nsdmi): Use it.
	(cp_parser_cache_group): Remove CPP_COMMA support.

Added:
    trunk/gcc/testsuite/g++.dg/cpp0x/nsdmi-defer5.C
Modified:
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/parser.c
    trunk/gcc/testsuite/ChangeLog
Comment 4 Paolo Carlini 2012-01-03 16:40:24 UTC
I suppose this can be closed as fixed.