public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/13886] New: Compiler crash on deeply nested template
@ 2004-01-27 16:08 david dot balazic at hermes dot si
  2004-01-27 16:11 ` [Bug c++/13886] " david dot balazic at hermes dot si
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: david dot balazic at hermes dot si @ 2004-01-27 16:08 UTC (permalink / raw)
  To: gcc-bugs

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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/13886] Compiler crash on deeply nested template
  2004-01-27 16:08 [Bug c++/13886] New: Compiler crash on deeply nested template david dot balazic at hermes dot si
@ 2004-01-27 16:11 ` david dot balazic at hermes dot si
  2004-01-29  3:08 ` giovannibajo at libero dot it
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: david dot balazic at hermes dot si @ 2004-01-27 16:11 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From david dot balazic at hermes dot si  2004-01-27 16:11 -------
Created an attachment (id=5596)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=5596&action=view)
Preprocessed source


-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/13886] Compiler crash on deeply nested template
  2004-01-27 16:08 [Bug c++/13886] New: Compiler crash on deeply nested template david dot balazic at hermes dot si
  2004-01-27 16:11 ` [Bug c++/13886] " david dot balazic at hermes dot si
@ 2004-01-29  3:08 ` giovannibajo at libero dot it
  2004-01-29  7:52 ` david dot balazic at hermes dot si
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: giovannibajo at libero dot it @ 2004-01-29  3:08 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-01-29 03:08 -------
What exactly would you expect? We just segfault because of a stack overflow 
here. You can track growing the stack if it helps a little, but I'm not sure 
what we should do about it.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/13886] Compiler crash on deeply nested template
  2004-01-27 16:08 [Bug c++/13886] New: Compiler crash on deeply nested template david dot balazic at hermes dot si
  2004-01-27 16:11 ` [Bug c++/13886] " david dot balazic at hermes dot si
  2004-01-29  3:08 ` giovannibajo at libero dot it
@ 2004-01-29  7:52 ` david dot balazic at hermes dot si
  2004-01-29  7:55 ` pinskia at gcc dot gnu dot org
  2004-01-30 13:05 ` giovannibajo at libero dot it
  4 siblings, 0 replies; 6+ messages in thread
From: david dot balazic at hermes dot si @ 2004-01-29  7:52 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From david dot balazic at hermes dot si  2004-01-29 07:52 -------
I expected it to work, of course.

I reported it, because it said so.

So deep template instantiations do not work with gcc ?
( I know the example I used for this report is silly, but there might be other,
more real life uses )

-- 


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/13886] Compiler crash on deeply nested template
  2004-01-27 16:08 [Bug c++/13886] New: Compiler crash on deeply nested template david dot balazic at hermes dot si
                   ` (2 preceding siblings ...)
  2004-01-29  7:52 ` david dot balazic at hermes dot si
@ 2004-01-29  7:55 ` pinskia at gcc dot gnu dot org
  2004-01-30 13:05 ` giovannibajo at libero dot it
  4 siblings, 0 replies; 6+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-01-29  7:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-01-29 07:55 -------
Actually I know that for the fact there is no way to increase the stack limit on cygwin except for 
recompiling the program itself (cc1plus).  I will look to see where the stack problem is and see if 
this is already fixed on the mainline.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |pinskia at gcc dot gnu dot
                   |                            |org
             Status|WAITING                     |NEW
     Ever Confirmed|                            |1
   Last reconfirmed|0000-00-00 00:00:00         |2004-01-29 07:55:52
               date|                            |


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug c++/13886] Compiler crash on deeply nested template
  2004-01-27 16:08 [Bug c++/13886] New: Compiler crash on deeply nested template david dot balazic at hermes dot si
                   ` (3 preceding siblings ...)
  2004-01-29  7:55 ` pinskia at gcc dot gnu dot org
@ 2004-01-30 13:05 ` giovannibajo at libero dot it
  4 siblings, 0 replies; 6+ messages in thread
From: giovannibajo at libero dot it @ 2004-01-30 13:05 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2004-01-30 13:04 -------
David,

ISO C++ says that a compliant C++ compile must implement at least 17 recursive 
levels for template instantiation. We do keep a default limit around 500 for a 
good reason, which is trying not to break stack or memory limits. By the look 
of your error logs, GCC instantiate about 3300 templates before dieing. 

There is no way you will ever be able to compile such a program on any C++ 
compiler on earth. If you do, you can as well try recompiling G++ with a larger 
stack size. Besides, the problem is *PURELY* academic, since no real-world code 
will ever look like that.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


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


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2004-01-30 13:05 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-01-27 16:08 [Bug c++/13886] New: Compiler crash on deeply nested template david dot balazic at hermes dot si
2004-01-27 16:11 ` [Bug c++/13886] " david dot balazic at hermes dot si
2004-01-29  3:08 ` giovannibajo at libero dot it
2004-01-29  7:52 ` david dot balazic at hermes dot si
2004-01-29  7:55 ` pinskia at gcc dot gnu dot org
2004-01-30 13:05 ` giovannibajo at libero dot it

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).