This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
c++/6730: Crash involving templates when compiling program
- From: bbaetz at student dot usyd dot edu dot au
- To: gcc-gnats at gcc dot gnu dot org
- Date: Mon, 20 May 2002 15:10:57 +1000
- Subject: c++/6730: Crash involving templates when compiling program
>Number: 6730
>Category: c++
>Synopsis: Crash involving templates when compiling program
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: ice-on-legal-code
>Submitter-Id: net
>Arrival-Date: Sun May 19 22:16:00 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: Bradley Baetz
>Release: 3.2 20020519 (experimental)
>Organization:
>Environment:
System: Linux tomato.home 2.4.18 #8 Thu Feb 28 22:43:37 EST 2002 i686 unknown
Architecture: i686
host: i686-pc-linux-gnu
build: i686-pc-linux-gnu
target: i686-pc-linux-gnu
configured with: ../gcc/configure --prefix=/home/bbaetz/gcc/ --enable-languages=c,c++,treelang --enable-threads=posix --disable-checking
>Description:
I was attempting to get the testcase in
http://groups.google.com/groups?selm=1018969434.13641.0.nnrp-07.3e31d362%40news.demon.co.uk
to work.
Uncommenting either of the usages of has_subscript_operator in main causes
a crash:
sub.cpp: In instantiation of `has_subscript_operator<int>':
sub.cpp:13: instantiated from here
sub.cpp:6: internal error: Segmentation fault
The first line is obviously illegal (a typo I made while I was playing
with the testcase), but I believe that the second should be OK.
>How-To-Repeat:
template<typename T>
class has_subscript_operator
{
private:
template <int> struct helper {};
template <class U> static int foo( helper<sizeof( &U::operator[] )> * );
public:
int value() { return 0; };
};
int main() {
// return has_subscript_operator<int>::value;
return has_subscript_operator<int>().value();
}
g++ -Wall sub.cc
>Fix:
Removing the unused template functions (which are unused in this
example) from the class avoids the crash.
>Release-Note:
>Audit-Trail:
>Unformatted: