Created attachment 25203 [details] Preprocessed source A function "f" taking a class and a set (variadic) of template classes as template parameters is written. If this function passes the variadic parameter to another one, the compiler fails with a segfault. Otherwise the compiler just works. This happens on Gentoo with gcc 4.6.1, on Fedora 15 with gcc-4.6.0, on the online service ideone (see http://ideone.com/yrIfa -- there is the original source too). On Gentoo I have the following output: $ g++ -v -save-temps -std=c++0x variadic_template.cpp -pedantic-errors Using built-in specs. Reading specs from /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/asneeded.specs COLLECT_GCC=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.1/g++ COLLECT_LTO_WRAPPER=/usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.1/lto-wrapper Target: x86_64-pc-linux-gnu Configured with: /var/tmp/portage/sys-devel/gcc-4.6.1-r1/work/gcc-4.6.1/configure --prefix=/usr --bindir=/usr/x86_64-pc-linux-gnu/gcc-bin/4.6.1 --includedir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/include --datadir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.1 --mandir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.1/man --infodir=/usr/share/gcc-data/x86_64-pc-linux-gnu/4.6.1/info --with-gxx-include-dir=/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/include/g++-v4 --host=x86_64-pc-linux-gnu --build=x86_64-pc-linux-gnu --disable-altivec --disable-fixed-point --without-ppl --without-cloog --enable-lto --enable-nls --without-included-gettext --with-system-zlib --disable-werror --enable-secureplt --enable-multilib --enable-libmudflap --disable-libssp --enable-libgomp --with-python-dir=/share/gcc-data/x86_64-pc-linux-gnu/4.6.1/python --enable-checking=release --enable-languages=c,c++,java,fortran --enable-shared --enable-threads=posix --enable-__cxa_atexit --enable-clocale=gnu --with-bugurl=http://bugs.gentoo.org/ --with-pkgversion='Gentoo 4.6.1-r1 p1.0, pie-0.4.5' Thread model: posix gcc version 4.6.1 (Gentoo 4.6.1-r1 p1.0, pie-0.4.5) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-pedantic-errors' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.1/cc1plus -E -quiet -v -D_GNU_SOURCE variadic_template.cpp -D_FORTIFY_SOURCE=2 -mtune=generic -march=x86-64 -std=c++0x -pedantic-errors -fpch-preprocess -o variadic_template.ii ignoring nonexistent directory "/usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/../../../../x86_64-pc-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/include/g++-v4 /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/include/g++-v4/x86_64-pc-linux-gnu /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/include/g++-v4/backward /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/include /usr/local/include /usr/lib/gcc/x86_64-pc-linux-gnu/4.6.1/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++0x' '-pedantic-errors' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/libexec/gcc/x86_64-pc-linux-gnu/4.6.1/cc1plus -fpreprocessed variadic_template.ii -quiet -dumpbase variadic_template.cpp -mtune=generic -march=x86-64 -auxbase variadic_template -pedantic-errors -std=c++0x -version -o variadic_template.s GNU C++ (Gentoo 4.6.1-r1 p1.0, pie-0.4.5) version 4.6.1 (x86_64-pc-linux-gnu) compiled by GNU C version 4.6.1, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++ (Gentoo 4.6.1-r1 p1.0, pie-0.4.5) version 4.6.1 (x86_64-pc-linux-gnu) compiled by GNU C version 4.6.1, GMP version 5.0.2, MPFR version 3.0.1-p4, MPC version 0.8.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 510fa67dba4694d68782d987f500559c variadic_template.cpp: In function ‘void f() [with Interface = I1, Actions = A1, A2]’: variadic_template.cpp:58:16: instantiated from here variadic_template.cpp:49:58: internal compiler error: Segmentation fault Please submit a full bug report, with preprocessed source if appropriate. See <http://bugs.gentoo.org/> for instructions.
Can you try reducing your testcase? 563 KB is definitely unmanageable.
Created attachment 25275 [details] Not-preprocessed source As requested, I attach a minimal source code with some comments. There are no external dependencies, just <iostream> gets #included. The compilation result is the same as already stated (segmentation fault during compilation).
I recently blogged about this issue: http://wp.me/pzWEm-9N.
Ah, ok, the below seems enough: template<typename Interface> struct A1 { }; template<template<class I> class... Actions> void g2() { g2<Actions...>(); } int main() { g2<A1>(); }
Program received signal SIGSEGV, Segmentation fault. [Switching to process 30771] tsubst_template_parms (parms=0x0, args=0x7ffff77a6d98, complain=3) at ../../gcc/gcc/cp/pt.c:9507 9507 TMPL_PARMS_DEPTH (parms) > TMPL_ARGS_DEPTH (args); (gdb) bt #0 tsubst_template_parms (parms=0x0, args=0x7ffff77a6d98, complain=3) at ../../gcc/gcc/cp/pt.c:9507 #1 0x00000000004c6d9a in tsubst_decl (t=0x7ffff77a7e60, args=0x7ffff77a6d98, complain=3) at ../../gcc/gcc/cp/pt.c:9789 #2 0x00000000004c3ce5 in tsubst (in_decl=<optimized out>, complain=3, args=0x7ffff77a6d98, t=0x7ffff77a7e60) at ../../gcc/gcc/cp/pt.c:10851 #3 tsubst (t=0x7ffff77a7e60, args=0x7ffff77a6d98, complain=3, in_decl=<optimized out>) at ../../gcc/gcc/cp/pt.c:10836 #4 0x00000000004c821f in tsubst_pack_expansion (t=0x7ffff77afe70, args=0x7ffff77a6f78, complain=3, in_decl=0x7ffff77a7f18) at ../../gcc/gcc/cp/pt.c:9298 #5 0x00000000004c656b in tsubst_template_args (t=0x7ffff77a6ac8, args=0x7ffff77a6d98, complain=3, in_decl=0x7ffff77a7f18) at ../../gcc/gcc/cp/pt.c:9400 #6 0x00000000004c1e46 in tsubst_copy_and_build (t=0x7ffff7fd9a50, args=0x7ffff77a6d98, complain=3, in_decl=0x7ffff77a7f18, function_p=1 '\001', integral_constant_expression_p=<optimized out>) at ../../gcc/gcc/cp/pt.c:13035 #7 0x00000000004c1c9e in tsubst_copy_and_build (t=0x7ffff77bd038, args=0x7ffff77a6d98, complain=3, in_decl=0x7ffff77a7f18, function_p=0 '\000', integral_constant_expression_p=0 '\000') at ../../gcc/gcc/cp/pt.c:13390 #8 0x00000000004bd239 in tsubst_expr (t=0x7ffff77bd038, args=0x7ffff77a6d98, complain=3, in_decl=0x7ffff77a7f18, integral_constant_expression_p=0 '\000') at ../../gcc/gcc/cp/pt.c:12935 #9 0x00000000004bdc70 in tsubst_expr (t=0x7ffff77a6b40, args=0x7ffff77a6d98, complain=3, in_decl=0x7ffff77a7f18, integral_constant_expression_p=0 '\000') at ../../gcc/gcc/cp/pt.c:12467 #10 0x00000000004bd2b1 in tsubst_expr (t=0x7ffff77bd000, args=0x7ffff77a6d98, complain=3, in_decl=0x7ffff77a7f18, integral_constant_expression_p=0 '\000') at ../../gcc/gcc/cp/pt.c:12632 #11 0x00000000004d0ccc in instantiate_decl (d=0x7ffff77aee00, defer_ok=<optimized out>, expl_inst_class_mem_p=<optimized out>) at ../../gcc/gcc/cp/pt.c:18305 #12 0x00000000004d34dc in instantiate_pending_templates (retries=<optimized out>) at ../../gcc/gcc/cp/pt.c:18402 #13 0x00000000004e8a4d in cp_write_global_declarations () at ../../gcc/gcc/cp/decl2.c:3713 #14 0x00000000007f11c2 in compile_file () at ../../gcc/gcc/toplev.c:564 #15 do_compile () at ../../gcc/gcc/toplev.c:1886 #16 toplev_main (argc=13, argv=0x7fffffffdf28) at ../../gcc/gcc/toplev.c:1962 #17 0x00007ffff7b81f82 in __libc_start_main (main=0x5a11b0 <main>, argc=13, ubp_av=0x7fffffffdf28, init=<optimized out>, fini=<optimized out>, rtld_fini=<optimized out>, stack_end=0x7fffffffdf18) at libc-start.c:226 #18 0x000000000048cf89 in _start () at ../sysdeps/x86_64/elf/start.S:113 (gdb)
Author: jason Date: Tue Apr 17 02:29:27 2012 New Revision: 186519 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186519 Log: PR c++/50303 * pt.c (tsubst_pack_expansion): Use tsubst_expr for template template parameters. Added: trunk/gcc/testsuite/g++.dg/cpp0x/variadic128.C Modified: trunk/gcc/cp/ChangeLog trunk/gcc/cp/pt.c trunk/gcc/testsuite/ChangeLog
Author: jason Date: Tue Apr 17 14:10:54 2012 New Revision: 186531 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=186531 Log: PR c++/50303 * pt.c (tsubst_pack_expansion): Use tsubst_expr for template template parameters. Added: branches/gcc-4_7-branch/gcc/testsuite/g++.dg/cpp0x/variadic128.C Modified: branches/gcc-4_7-branch/gcc/cp/ChangeLog branches/gcc-4_7-branch/gcc/cp/pt.c branches/gcc-4_7-branch/gcc/testsuite/ChangeLog
Fixed for 4.7.1.