CRTP does not seem to work together with variadic templates.
On a larger program, type canonization seems to be faulty and leads to a g++
crash.

Source code:
struct a {};

template < typename T, typename ENCLOSING >
struct base;

template < typename ENCLOSING >
struct base< a, ENCLOSING >
{};

template < typename... T >
struct derived
 : public base< T, derived< T... > >...
{};

int main()
{
 derived< a > instance;
 base< a, derived< a > >& a_instance = instance;
}

Output of g++ variadic-crtp.cc -std=c++0x:
variadic-crtp.cc: In function 'int main()':
variadic-crtp.cc:18:41: error: invalid initialization of reference of type
'base<a, derived<a> >&' from expression of type 'derived<a>'

Output of g++ -v:
Using built-in specs.
Target: i386-apple-darwin9
Configured with: ../gcc-4.5-20091001/configure --prefix=/opt/local
--build=i386-apple-darwin9 --enable-languages=c,c++,objc,obj-c++
--libdir=/opt/local/lib/gcc45 --includedir=/opt/local/include/gcc45
--infodir=/opt/local/share/info --mandir=/opt/local/share/man
--with-local-prefix=/opt/local --with-system-zlib --disable-nls
--program-suffix=-mp-4.5 --with-gxx-include-dir=/opt/local/include/gcc45/c++/
--with-gmp=/opt/local --with-mpfr=/opt/local
Thread model: posix
gcc version 4.5.0 20091001 (experimental) (GCC)


-- 
           Summary: Canonical type with variadic templates and CRTP
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: alban dot linard at gmail dot com
 GCC build triplet: i686-apple-darwin9
  GCC host triplet: i686-apple-darwin9
GCC target triplet: i686-apple-darwin9


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

Reply via email to