The following code generates an tree check error in cp/pt.c of gcc 4.5 trunk
(11/15/2009).  This is a kernel that reproduces the error in a larger project. 
Both the kernel and original code compile and run correctly in previous
versions of gcc.

template<typename T>
struct A
{
  static const int size = 1;
};


template<int Integral>
struct B
{
  typedef int type;
};


template<typename T>
struct C
{
  typedef int type;
};


template<typename X, typename Y = void>
struct D
{
  typedef typename C<X>::type        T;
  typedef A<T>                       AT;
  typedef typename B<AT::size>::type type;
};


template<typename X> 
struct D<X&, void>
{
  typedef typename C<X>::type        T;
  typedef A<T>                       AT;
  typedef typename B<AT::size>::type type;
};

main()
{
  D<bool&> t;
}


gcc -v -save-temps -o test test.cc             
Using built-in specs.
COLLECT_GCC=gcc
COLLECT_LTO_WRAPPER=/usr/local/gnu/gcc-4.5.trunk.10.14.09/libexec/gcc/i686-pc-linux-gnu/4.5.0/lto-wrapper
Target: i686-pc-linux-gnu
Configured with: ../gcc.trunk/configure --enable-languages=c++
--prefix=/usr/local/gnu/gcc-4.5.trunk.10.14.09
--with-mpfr=/usr/local/gnu/mpfr-2.4.1
Thread model: posix
gcc version 4.5.0 20091110 (experimental) (GCC) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'test' '-mtune=generic'

/usr/local/gnu/gcc-4.5.trunk.10.14.09/libexec/gcc/i686-pc-linux-gnu/4.5.0/cc1plus
-E -quiet -v -D_GNU_SOURCE test.cc -mtune=generic -fpch-preprocess -o test.ii
ignoring nonexistent directory
"/usr/local/gnu/gcc-4.5.trunk.10.14.09/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:

/usr/local/gnu/gcc-4.5.trunk.10.14.09/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0

/usr/local/gnu/gcc-4.5.trunk.10.14.09/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/i686-pc-linux-gnu

/usr/local/gnu/gcc-4.5.trunk.10.14.09/lib/gcc/i686-pc-linux-gnu/4.5.0/../../../../include/c++/4.5.0/backward
 /usr/local/include
 /usr/local/gnu/gcc-4.5.trunk.10.14.09/include
 /usr/local/gnu/gcc-4.5.trunk.10.14.09/lib/gcc/i686-pc-linux-gnu/4.5.0/include

/usr/local/gnu/gcc-4.5.trunk.10.14.09/lib/gcc/i686-pc-linux-gnu/4.5.0/include-fixed
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-o' 'test' '-mtune=generic'

/usr/local/gnu/gcc-4.5.trunk.10.14.09/libexec/gcc/i686-pc-linux-gnu/4.5.0/cc1plus
-fpreprocessed test.ii -quiet -dumpbase test.cc -mtune=generic -auxbase test
-version -o test.s
GNU C++ (GCC) version 4.5.0 20091110 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.5.0 20091110 (experimental), GMP version
4.3.1, MPFR version 2.4.1-p5
warning: GMP header version 4.3.1 differs from library version 4.1.4.
warning: MPFR header version 2.4.1-p5 differs from library version 2.3.0.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
GNU C++ (GCC) version 4.5.0 20091110 (experimental) (i686-pc-linux-gnu)
        compiled by GNU C version 4.5.0 20091110 (experimental), GMP version
4.3.1, MPFR version 2.4.1-p5
warning: GMP header version 4.3.1 differs from library version 4.1.4.
warning: MPFR header version 2.4.1-p5 differs from library version 2.3.0.
GGC heuristics: --param ggc-min-expand=30 --param ggc-min-heapsize=4096
Compiler executable checksum: a2f4d0ba16c13073ade98a90c4f4dd49
test.cc: In instantiation of 'D<bool&>':
test.cc:41:12:   instantiated from here
test.cc:36:38: internal compiler error: tree check: accessed elt 2 of tree_vec
with 1 elts in tsubst, at cp/pt.c:9721
Please submit a full bug report,
with preprocessed source if appropriate.
See <http://gcc.gnu.org/bugs.html> for instructions.


-- 
           Summary: 4.5 fails
           Product: gcc
           Version: 4.5.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: nthomas at cs dot tamu dot edu


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

Reply via email to