[Bug c++/57239] cannot handle inner/nested class templates with non-type parameter packs that were declared in the outer/containing class
scottbaldwin at gmail dot com
gcc-bugzilla@gcc.gnu.org
Wed Jun 26 10:55:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57239
--- Comment #6 from etherice <scottbaldwin at gmail dot com> ---
(In reply to Jonathan Wakely from comment #4)
> Until someone analyses it and convinces themselves it's a bug.
>
> Not providing a complete testcase doesn't help. Code missing headers, even
> standard ones, is not complete, and certainly doesn't compile "out of the
> box" because I need to add headers. http://gcc.gnu.org/bugs/ clearly says
> not to leave headers out, why should I have to figure out which headers you
> failed to include in the testcase to analyse your bug report?
----------------------------------------
1) Did you see the reply from Daniel Krügler? He included a complete example.
----------------------------------------
2) My example was complete except for needing a couple #includes for <iostream>
and <type_traits>. Here it is w/ those includes:
#include <type_traits>
#include <iostream>
template<bool BoolVal, char CharVal>
struct Foo {};
template<typename... Ts>
struct is_instantiation_of__nontypes
{
template<template<Ts...> class TT, typename T>
struct check : std::false_type {};
template<template<Ts...> class TT, Ts... Args>
struct check<TT, TT<Args...>> : std::true_type {};
};
int main() {
using FooInstantiation = Foo<false, 'x'>;
std::cout << ((is_instantiation_of__nontypes<bool, char>::check<Foo,
FooInstantiation>::value) ? "yes" : "no") << std::endl;
}
----------------------------------------
3) clang version 3.3 (trunk 176796) compiles it fine and produces the correct
output of "yes", while gcc (all versions) blow up with some variant of:
error: ‘Ts ...’ is not a valid type for a template non-type parameter
struct check<TT, TT<Args...>> : std::true_type {};
^
error: template argument 2 is invalid
struct check<TT, TT<Args...>> : std::true_type {};
^
error: type/value mismatch at argument 1 in template parameter list for
‘template<class ... Ts> template<template<template<Ts ...<anonymous> > class
TT, class T> template<class ... Ts> template<Ts ...<anonymous> > class TT,
class T> struct is_instantiation_of__nontypes<Ts>::check’
std::cout << ((is_instantiation_of__nontypes<bool, char>::check<Foo,
FooInstantiation>::value) ? "yes" : "no") << std::endl;
error: expected a template of type ‘template<class ... Ts> template<Ts
...<anonymous> > class TT’, got ‘template<bool BoolVal, char CharVal> struct
Foo’
----------------------------------------
4) Convincing oneself that this is a bug should not be difficult. Section
14.1.15 of the C++11 standard makes it very clear that this code contains a
valid expansion of a non-type template parameter pack declared in a different
template-parameter-list. It even offers a very similar example, taken directly
from § 14.1.15:
template<class... T> struct value_holder {
template<T... Values> apply { }; // Values is a non-type template parameter
pack
// and a pack expansion
};
More information about the Gcc-bugs
mailing list