public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c++/30716] New: recursive templates compilation fault
@ 2007-02-06 19:10 generatorglukoff at gmail dot com
2007-02-07 0:32 ` [Bug c++/30716] " fang at csl dot cornell dot edu
2007-02-07 9:55 ` rguenth at gcc dot gnu dot org
0 siblings, 2 replies; 3+ messages in thread
From: generatorglukoff at gmail dot com @ 2007-02-06 19:10 UTC (permalink / raw)
To: gcc-bugs
I had tried to compile code like
template<int dim> class cls {
cls<dim-1> c[16];
};
template<> class cls<0> {
};
int main() {
cls<200> c;
return 0;
}
and had error:
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
I think, in this case better output maybe something like "no enough memory",
"unable to compile" etc.
Information as defined in http://gcc.gnu.org/bugs.html
- the options given when GCC was configured/built
--prefix=/usr --libexecdir=/usr/lib --enable-shared --enable-threads=posix
--enable-__cxa_atexit --enable-clocale=gnu --enable-languages=c,c++
- the complete command line that triggers the bug
g++ bug.cpp
- the compiler output (error messages, warnings, etc.)
g++: Internal error: Segmentation fault (program cc1plus)
Please submit a full bug report.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
- the preprocessed file (*.i*) that triggers the bug, generated by adding
-save-temps to the complete compilation command, or, in the case of a bug
report for the GNAT front end, a complete set of source files (see below)
Reading specs from /usr/lib/gcc/i686-pc-linux-gnu/3.4.3/specs
Configured with: ../gcc-3.4.3/configure --prefix=/usr --libexecdir=/usr/lib
--enable-shared --enable-threads=posix --enable-__cxa_atexit
--enable-clocale=gnu --enable-languages=c,c++
Thread model: posix
gcc version 3.4.3
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/cc1plus -E -quiet -v -D_GNU_SOURCE
bug.cpp -mtune=pentiumpro
ignoring nonexistent directory
"/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../i686-pc-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/i686-pc-linux-gnu
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/../../../../include/c++/3.4.3/backward
/usr/local/include
/usr/lib/gcc/i686-pc-linux-gnu/3.4.3/include
/usr/include
End of search list.
# 1 "bug.cpp"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "bug.cpp"
template<int dim> class cls {
cls<dim-1> c[16];
};
template<> class cls<0> {
};
int main() {
cls<200> c;
return 0;
}
--
Summary: recursive templates compilation fault
Product: gcc
Version: 3.4.3
Status: UNCONFIRMED
Severity: minor
Priority: P3
Component: c++
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: generatorglukoff at gmail dot com
GCC build triplet: i686-pc-linux-gnu
GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30716
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/30716] recursive templates compilation fault
2007-02-06 19:10 [Bug c++/30716] New: recursive templates compilation fault generatorglukoff at gmail dot com
@ 2007-02-07 0:32 ` fang at csl dot cornell dot edu
2007-02-07 9:55 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: fang at csl dot cornell dot edu @ 2007-02-07 0:32 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from fang at csl dot cornell dot edu 2007-02-07 00:32 -------
Ahh, exploding recursive templates...
For future reference, you could limit the recursion depth explicitly, using
-ftemplate-depth-n
from a gcc-3.4.0 man page:
Set the maximum instantiation depth for template classes to n. A limit on the
template instantiation depth is needed to detect endless recursions during
template class instantiation. ANSI/ISO C++ conforming programs must not rely
on a maximum depth greater than 17.
I think 42 would seem more appropriate than 17, but that is for The Committee
to decide. :)
--
fang at csl dot cornell dot edu changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |fang at csl dot cornell dot
| |edu
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30716
^ permalink raw reply [flat|nested] 3+ messages in thread
* [Bug c++/30716] recursive templates compilation fault
2007-02-06 19:10 [Bug c++/30716] New: recursive templates compilation fault generatorglukoff at gmail dot com
2007-02-07 0:32 ` [Bug c++/30716] " fang at csl dot cornell dot edu
@ 2007-02-07 9:55 ` rguenth at gcc dot gnu dot org
1 sibling, 0 replies; 3+ messages in thread
From: rguenth at gcc dot gnu dot org @ 2007-02-07 9:55 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from rguenth at gcc dot gnu dot org 2007-02-07 09:55 -------
note the size of class cls grows exponentially with its template parameter.
--
rguenth at gcc dot gnu dot org changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |INVALID
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=30716
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-02-07 9:55 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-02-06 19:10 [Bug c++/30716] New: recursive templates compilation fault generatorglukoff at gmail dot com
2007-02-07 0:32 ` [Bug c++/30716] " fang at csl dot cornell dot edu
2007-02-07 9:55 ` rguenth at gcc dot gnu dot org
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).