http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54080
Bug #: 54080 Summary: g++ crashes when compiling the following file Classification: Unclassified Product: gcc Version: 4.7.1 Status: UNCONFIRMED Severity: normal Priority: P3 Component: c++ AssignedTo: unassig...@gcc.gnu.org ReportedBy: m1010...@gmail.com $ cat y.cpp template <class T> class vector { }; template <template <typename U> class Container, typename Func > vector<int> foo(const Container<int>& input, const Func &func) { } template <template <typename U> class OutType, typename Func1, typename FuncRest > auto foo(const vector<int> &input, const Func1 &func1, const FuncRest funcrest) -> decltype(foo<vector>(foo(input, func1), funcrest)) { return; } int main() { vector<int> v1; foo<vector>(v1, 1, 1); } $ g++ -v -save-temps -std=c++11 y.cpp Using built-in specs. COLLECT_GCC=g++ COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/lto-wrapper Target: x86_64-unknown-linux-gnu Configured with: /build/src/gcc-4.7-20120721/configure --prefix=/usr --libdir=/usr/lib --libexecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --with-bugurl=https://bugs.archlinux.org/ --enable-languages=c,c++,ada,fortran,go,lto,objc,obj-c++ --enable-shared --enable-threads=posix --with-system-zlib --enable-__cxa_atexit --disable-libunwind-exceptions --enable-clocale=gnu --disable-libstdcxx-pch --enable-libstdcxx-time --enable-gnu-unique-object --enable-linker-build-id --with-ppl --enable-cloog-backend=isl --disable-ppl-version-check --disable-cloog-version-check --enable-lto --enable-gold --enable-ld=default --enable-plugin --with-plugin-ld=ld.gold --with-linker-hash-style=gnu --enable-multilib --disable-libssp --disable-build-with-cxx --disable-build-poststage1-with-cxx --enable-checking=release Thread model: posix gcc version 4.7.1 20120721 (prerelease) (GCC) COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/cc1plus -E -quiet -v -D_GNU_SOURCE y.cpp -mtune=generic -march=x86-64 -std=c++11 -fpch-preprocess -o y.ii ignoring nonexistent directory "/usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/../../../../x86_64-unknown-linux-gnu/include" #include "..." search starts here: #include <...> search starts here: /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/../../../../include/c++/4.7.1 /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/../../../../include/c++/4.7.1/x86_64-unknown-linux-gnu /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/../../../../include/c++/4.7.1/backward /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/include /usr/local/include /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/include-fixed /usr/include End of search list. COLLECT_GCC_OPTIONS='-v' '-save-temps' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/lib/gcc/x86_64-unknown-linux-gnu/4.7.1/cc1plus -fpreprocessed y.ii -quiet -dumpbase y.cpp -mtune=generic -march=x86-64 -auxbase y -std=c++11 -version -o y.s GNU C++ (GCC) version 4.7.1 20120721 (prerelease) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.7.1 20120721 (prerelease), GMP version 5.0.5, MPFR version 3.1.1, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 GNU C++ (GCC) version 4.7.1 20120721 (prerelease) (x86_64-unknown-linux-gnu) compiled by GNU C version 4.7.1 20120721 (prerelease), GMP version 5.0.5, MPFR version 3.1.1, MPC version 0.9 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 9968e81036a8f762508137542633c004 ‘ Internal compiler error: Error reporting routines re-entered. Please submit a full bug report, with preprocessed source if appropriate. See <https://bugs.archlinux.org/> for instructions. $ cat y.ii # 1 "y.cpp" # 1 "<command-line>" # 1 "y.cpp" template <class T> class vector { }; template <template <typename U> class Container, typename Func > vector<int> foo(const Container<int>& input, const Func &func) { } template <template <typename U> class OutType, typename Func1, typename FuncRest > auto foo(const vector<int> &input, const Func1 &func1, const FuncRest funcrest) -> decltype(foo<vector>(foo(input, func1), funcrest)) { return; } int main() { vector<int> v1; foo<vector>(v1, 1, 1); } On a possibly unrelated note, changing the "return;" in foo to "return vector<int>();" will cause the file to compile without a compiler crash.