[Bug c++/57765] New: [C++11] Variadic Template Specialization does not follow the INCITS/ISO/IEC 14882-2011 standard
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57765 Bug ID: 57765 Summary: [C++11] Variadic Template Specialization does not follow the INCITS/ISO/IEC 14882-2011 standard Product: gcc Version: 4.8.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ Assignee: unassigned at gcc dot gnu.org Reporter: aaronngray.lists at gmail dot com Prompted by a Stack Overflow article :- http://stackoverflow.com/questions/17332749/vs2013-fails-with-variadic-template-specialization/ There seems to be anomalies between GCC 4.8.1's 0x11 implementation and the standard. It shows the code :- template struct OpF; template struct OpF { }; int foo(int x) { return 0; } OpF f; Given the C++ Standard outlaws this code, see 14.1 paragraphs 11 and 15. Note that GCC accepts the following code with either -std=gnu++11 or -std=c++11, the latter should be strict to the standard. Also given these paragraphs were in the draft C++ standard too. On the other hand GCC 4.8.1 will not accept a simple trailing 'int' parameter after a variadic template list. template < typename TR, typename ... Ts, int i> TR tester(Ts...); // error: parameter pack ‘Ts’ must be at the end of the template parameter list There seems to be quite an inconsistency even in an augmentation to the standard. On a personal note both these forms are syntactically correct but not semantically by the standard, given that this is just a simple type based pattern matching problem as far as I can see it would be nice to have it within the language as it seems to fit naturally with requirements.
[Bug c++/57765] [C++11] Variadic Template Specialization does not follow the INCITS/ISO/IEC 14882-2011 standard
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57765 --- Comment #2 from AaronNGray --- Interesting ...from the standard, not in braces :- "A template parameter pack of a function template shall not be followed by another template parameter unless that template parameter can be deduced or has a default argument" The two paragraphs in full :- 14.1 [11] If a template-parameter of a class 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. If a template-parameter of a primary class template or alias template is a template parameter pack, it shall be the last template-parameter. A template parameter pack of a function template shall not be followed by another template parameter unless that template parameter can be deduced or has a default argument (14.8.2). 14.1 [15] If a template-parameter is a type-parameter with an ellipsis prior to its optional identifier or is a parameter-declaration that declares a parameter pack (8.3.5), then the template-parameter is a template parameter pack (14.5.3). A template parameter pack that is a parameter-declaration whose type contains one or more unexpanded parameter packs is a pack expansion. Similarly, a template parameter pack that is a type-parameter with a template-parameter-list containing one or more unexpanded parameter packs is a pack expansion. A template parameter pack that is a pack expansion shall not expand a parameter pack declared in the same template-parameter-list.
[Bug c++/57765] [C++11] Variadic Template Specialization does not follow the INCITS/ISO/IEC 14882-2011 standard
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57765 AaronNGray changed: What|Removed |Added Status|UNCONFIRMED |RESOLVED Resolution|--- |INVALID --- Comment #4 from AaronNGray --- If a template-parameter of a primary class template or alias template is a template parameter pack, it shall be the last template-parameter. template struct OpF { };