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.
Confirmed, worked with 4.4 with checking enabled.
Shorter testcase (without default parameter): ================================= struct A { static const int N = 0; }; template<int> struct B {}; template<typename T, int> struct C { typedef T U; B<U::N> b; }; template<typename T> struct C<T*, 0> { B<T::N> b; }; C<A*, 0> c; =================================
Mine.
Patch submitted to http://gcc.gnu.org/ml/gcc-patches/2009-11/msg01630.html
Subject: Bug 42069 Author: dodji Date: Mon Nov 30 09:58:20 2009 New Revision: 154768 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=154768 Log: Fix PR c++/42069 gcc/cp/ChangeLog: PR c++/42069 * pt.c (convert_template_argument): Strip typedefs from SCOPE_REFs. gcc/testsuite/ChangeLog: PR c++/42069 * g++.dg/template/typedef23.C: New test. Added: trunk/gcc/testsuite/g++.dg/template/typedef23.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Fixed in 4.5.
Subject: Bug 42069 Author: hjl Date: Fri Dec 11 23:36:24 2009 New Revision: 155184 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=155184 Log: Backport testcases from trunk. 2009-12-11 H.J. Lu <hongjiu.lu@intel.com> Backport from mainline: 2009-12-11 Dodji Seketeli <dodji@redhat.com> PR c++/42225 * g++.dg/template/typedef24.C: New test. * g++.dg/template/typedef25.C: New test. 2009-12-11 Dodji Seketeli <dodji@redhat.com> PR c++/42251 * g++.dg/template/const3.C: New test. 2009-12-10 Jakub Jelinek <jakub@redhat.com> PR c++/42317 * g++.dg/opt/dtor2.C: New test. * g++.dg/opt/dtor2.h: New file. * g++.dg/opt/dtor2-aux.cc: New file. 2009-12-10 Jan Hubicka <jh@suse.cz> PR middle-end/42110 * g++.dg/torture/pr42110.C: new file. 2009-12-07 Jakub Jelinek <jakub@redhat.com> PR debug/42244 * gcc.dg/debug/pr42244.c: New test. 2009-12-04 David Daney <ddaney@caviumnetworks.com> PR rtl-optimization/42164 * gcc.c-torture/compile/pr42164.c: New test. 2009-12-03 Jason Merrill <jason@redhat.com> PR c++/41611 * g++.dg/abi/guard2.C: New. 2009-12-03 Dodji Seketeli <dodji@redhat.com> PR c++/42217 * g++.dg/other/bitfield4.C: New test. 2009-12-03 Jakub Jelinek <jakub@redhat.com> PR c++/42256 * g++.dg/inherit/thunk11.C: New test. * g++.dg/inherit/thunk11.h: New file. * g++.dg/inherit/thunk11-aux.cc: New file. 2009-12-01 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42237 * gcc.c-torture/compile/pr42237.c: New test. 2009-12-01 Paolo Carlini <paolo.carlini@oracle.com> PR c++/42057 * g++.dg/parse/crash54.C: New. 2009-11-30 Martin Jambor <mjambor@suse.cz> PR middle-end/42196 * gcc.c-torture/compile/pr42196-1.c: New test. * gcc.c-torture/compile/pr42196-2.c: New test. * gcc.c-torture/compile/pr42196-3.c: New test. 2009-11-30 Dodji Seketeli <dodji@redhat.com> PR c++/42069 * g++.dg/template/typedef23.C: New test. 2009-11-29 H.J. Lu <hongjiu.lu@intel.com> PR tree-optimization/41961 * g++.dg/tree-ssa/pr41961.C: New. 2009-11-29 Ira Rosen <irar@il.ibm.com> PR tree-optimization/42193 * gcc.dg/vect/pr42193.c: New test. 2009-11-28 Richard Guenther <rguenther@suse.de> PR tree-optimization/42183 * g++.dg/torture/pr42183.C: New testcase. 2009-11-27 Martin Jambor <mjambor@suse.cz> PR middle-end/42006 * gcc.c-torture/execute/pr42006.c: New test. 2009-11-27 Michael Matz <matz@suse.de> PR rtl-optimization/42084 * gcc.dg/pr42084.c: New test. 2009-11-27 Michael Matz <matz@suse.de> PR c++/41906 * g++.dg/tree-ssa/pr41906.C: New testcase. 2009-11-26 Michael Matz <matz@suse.de> PR tree-optimization/41905 * g++.dg/tree-ssa/pr41905.C: New testcase. 2009-11-24 Richard Guenther <rguenther@suse.de> PR tree-optimization/42142 * gcc.c-torture/execute/pr42142.c: New testcase. 2009-11-24 Martin Jambor <mjambor@suse.cz> PR tree-optimization/42154 * gcc.c-torture/execute/pr42154.c: New test. 2009-11-21 Martin Jambor <mjambor@suse.cz> PR middle-end/42025 * gcc.c-torture/compile/pr42025-1.c: New test. * gcc.c-torture/compile/pr42025-2.c: New test. 2009-11-21 Jakub Jelinek <jakub@redhat.com> PR tree-optimization/42078 * gcc.dg/pr42078.c: New test. Added: branches/gcc-4_4-branch/gcc/testsuite/g++.dg/abi/guard2.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/abi/guard2.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/inherit/thunk11-aux.cc - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/inherit/thunk11-aux.cc branches/gcc-4_4-branch/gcc/testsuite/g++.dg/inherit/thunk11.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/inherit/thunk11.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/inherit/thunk11.h - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/inherit/thunk11.h branches/gcc-4_4-branch/gcc/testsuite/g++.dg/opt/dtor2-aux.cc - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/opt/dtor2-aux.cc branches/gcc-4_4-branch/gcc/testsuite/g++.dg/opt/dtor2.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/opt/dtor2.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/opt/dtor2.h - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/opt/dtor2.h branches/gcc-4_4-branch/gcc/testsuite/g++.dg/other/bitfield4.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/other/bitfield4.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/parse/crash54.C - copied unchanged from r155172, trunk/gcc/testsuite/g++.dg/parse/crash54.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/const3.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/template/const3.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef23.C - copied unchanged from r155181, trunk/gcc/testsuite/g++.dg/template/typedef23.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef24.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/template/typedef24.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/template/typedef25.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/template/typedef25.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42110.C - copied unchanged from r155170, trunk/gcc/testsuite/g++.dg/torture/pr42110.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/torture/pr42183.C - copied unchanged from r155181, trunk/gcc/testsuite/g++.dg/torture/pr42183.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/tree-ssa/pr41905.C - copied unchanged from r155182, trunk/gcc/testsuite/g++.dg/tree-ssa/pr41905.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/tree-ssa/pr41906.C - copied unchanged from r155182, trunk/gcc/testsuite/g++.dg/tree-ssa/pr41906.C branches/gcc-4_4-branch/gcc/testsuite/g++.dg/tree-ssa/pr41961.C - copied unchanged from r155181, trunk/gcc/testsuite/g++.dg/tree-ssa/pr41961.C branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42025-1.c - copied unchanged from r155182, trunk/gcc/testsuite/gcc.c-torture/compile/pr42025-1.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42025-2.c - copied unchanged from r155182, trunk/gcc/testsuite/gcc.c-torture/compile/pr42025-2.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42164.c - copied unchanged from r155170, trunk/gcc/testsuite/gcc.c-torture/compile/pr42164.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42196-1.c - copied unchanged from r155181, trunk/gcc/testsuite/gcc.c-torture/compile/pr42196-1.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42196-2.c - copied unchanged from r155181, trunk/gcc/testsuite/gcc.c-torture/compile/pr42196-2.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42196-3.c - copied unchanged from r155181, trunk/gcc/testsuite/gcc.c-torture/compile/pr42196-3.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/compile/pr42237.c - copied unchanged from r155171, trunk/gcc/testsuite/gcc.c-torture/compile/pr42237.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42006.c - copied unchanged from r155181, trunk/gcc/testsuite/gcc.c-torture/execute/pr42006.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42142.c - copied unchanged from r155182, trunk/gcc/testsuite/gcc.c-torture/execute/pr42142.c branches/gcc-4_4-branch/gcc/testsuite/gcc.c-torture/execute/pr42154.c - copied unchanged from r155182, trunk/gcc/testsuite/gcc.c-torture/execute/pr42154.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/debug/pr42244.c - copied unchanged from r155170, trunk/gcc/testsuite/gcc.dg/debug/pr42244.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42078.c - copied unchanged from r155182, trunk/gcc/testsuite/gcc.dg/pr42078.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/pr42084.c - copied unchanged from r155182, trunk/gcc/testsuite/gcc.dg/pr42084.c branches/gcc-4_4-branch/gcc/testsuite/gcc.dg/vect/pr42193.c - copied unchanged from r155181, trunk/gcc/testsuite/gcc.dg/vect/pr42193.c Modified: branches/gcc-4_4-branch/gcc/testsuite/ChangeLog