[Bug c++/36413] New: Bug with variadic templates (-std=c++0x)

2008-06-01 Thread fred at tigen dot org
Bug while testing variadic templates in both c++0x & gnu++0x modes.
The compiler itself says:
"Test.cpp:22: internal compiler error: in finish_member_declaration, at
cp/semantics.c:2311
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions."


 GCC OUTPUT 


Using built-in specs.
Target: x86_64-unknown-linux-gnu
Configured with: ../configure --prefix=/usr --enable-shared
--enable-languages=c,c++ --enable-threads=posix --enable-__cxa_atexit
--disable-multilib --libdir=/usr/lib --libexecdir=/usr/lib --enable-clocale=gnu
--disable-libstdcxx-pch --with-tune=generic --disable-werror
--enable-cheching=release --program-suffix=-4.4
--enable-version-specific-runtime-libs
Thread model: posix
gcc version 4.4.0 20080530 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-std=c++0x' '-mtune=generic'
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/cc1plus -quiet -v -D_GNU_SOURCE
Test.cpp -quiet -dumpbase Test.cpp -mtune=generic -auxbase Test -std=c++0x
-version -o /tmp/ccAHpJPe.s
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/../../../../x86_64-unknown-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/c++

/usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/c++/x86_64-unknown-linux-gnu
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include/c++/backward
 /usr/local/include
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include
 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.4.0/include-fixed
 /usr/include
End of search list.
GNU C++ (GCC) version 4.4.0 20080530 (experimental) (x86_64-unknown-linux-gnu)
compiled by GNU C version 4.4.0 20080530 (experimental), GMP version
4.2.2, MPFR version 2.3.1.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: 4ec09757f69fad896c3c6e042e6400dd
Test.cpp: In instantiation of 'Apply, TypeTuple >
>':
Test.cpp:24:   instantiated from 'Apply, TypeTuple > >'
Test.cpp:35:   instantiated from here
Test.cpp:22: internal compiler error: in finish_member_declaration, at
cp/semantics.c:2311
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


 SOURCE 


// Type tuples
template  struct TypeTuple;

// Tag management
template  struct SomeTag;

template 
struct RemoveTag {
typedef T Type;
};

template 
struct RemoveTag> {
typedef T Type;
};

// Remove tags from TupB to TupA
template  struct Apply;

template 
struct Apply, TypeTuple> {
typedef typename RemoveTag::Type A1;
typedef Apply, TypeTuple> Next;
typedef typename Next::Tuple Tuple;
};

template 
struct Apply, TypeTuple<>> {
typedef TypeTuple Tuple;
};

// Bug ?
int main(int argc, const char *argv[])
{
typedef Apply, TypeTuple>>::Tuple Tuple;
return 0;
}


-- 
   Summary: Bug with variadic templates (-std=c++0x)
   Product: gcc
   Version: 4.4.0
Status: UNCONFIRMED
  Severity: normal
      Priority: P3
 Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: fred at tigen dot org
 GCC build triplet: x86_64-unknown-linux-gnu
  GCC host triplet: x86_64-unknown-linux-gnu
GCC target triplet: x86_64-unknown-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36413



[Bug c++/36413] Bug with variadic templates (-std=c++0x)

2008-06-01 Thread fred at tigen dot org


--- Comment #1 from fred at tigen dot org  2008-06-01 20:43 ---
This code is sufficient to cause the bug.
It simply builds recursively a TypeTuple formed of all types given as template
parameters (TypeTuple):

// Type tuples
template  struct TypeTuple;

// Transfer types from TypeTuple TupB to Apply<>::Tuple
template  struct Apply;

template 
struct Apply, B1, Bn...> {
typedef B1 A1;
typedef Apply, Bn...> Next;
typedef typename Next::Tuple Tuple;
};

template 
struct Apply> {
typedef TypeTuple Tuple;
};

// Bug ?
int main(int argc, const char *argv[])
{
typedef Apply, int, char>::Tuple Tuple;
return 0;
}


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36413