[Bug c++/13886] New: Compiler crash on deeply nested template
david dot balazic at hermes dot si
gcc-bugzilla@gcc.gnu.org
Tue Jan 27 16:08:00 GMT 2004
Version :
$ g++ -v
Reading specs from /usr/lib/gcc-lib/i686-pc-cygwin/3.3.1/specs
Configured with: /netrel/src/gcc-3.3.1-2/configure
--enable-languages=c,c++,f77,java --enable-libgcj --enable-threads=posix
--with-system-zlib --enable-nls --without-included-gettext --enable-interpreter
--enable-sjlj-exceptions --disable-version-specific-runtime-libs --enable-shared
--build=i686-pc-linux --host=i686-pc-cygwin --target=i686-pc-cygwin
--prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib
--includedir=/nonexistent/include --libexecdir=/usr/sbin
Thread model: posix
gcc version 3.3.1 (cygming special)
command line :
g++ -save-temps -ftemplate-depth-10000 -Wall -ansi -pedantic addfirstn_tmpl.cpp
Source snippet ( full preprocessed source attached below ) :
/* Compute the sum of first 1000000000 natural numbers */
#include <iostream>
using namespace std;
const static int32_t i=1000000000;
template <int32_t n>
int64_t sum()
{
return sum<n-1>() + n;
}
template <>
int64_t sum<1>()
{
return 1;
}
int main(int,char**)
{
cout << "Sum of first " << i << " natural numbers is " << sum<i>() << endl;
}
// end of source code
Compiler output :
addfirstn_tmpl.cpp: In function `int64_t sum() [with long int n = 999996673]':
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996674]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996675]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996676]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996677]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996678]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996679]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996680]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996681]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996682]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996683]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996684]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996685]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996686]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996687]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996688]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996689]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999996690]'
.
. [ snip ]
.
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999999997]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999999998]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
999999999]'
addfirstn_tmpl.cpp:26: instantiated from `int64_t sum() [with long int n =
1000000000]'
addfirstn_tmpl.cpp:37: instantiated from here
addfirstn_tmpl.cpp:25: internal compiler error: Segmentation fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
--
Summary: Compiler crash on deeply nested template
Product: gcc
Version: 3.3.1
Status: UNCONFIRMED
Severity: normal
Priority: P2
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: david dot balazic at hermes dot si
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: i686-pc-linux
GCC host triplet: i686-pc-cygwin
GCC target triplet: i686-pc-cygwin
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=13886
More information about the Gcc-bugs
mailing list