public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: bbaetz@student.usyd.edu.au
To: gcc-gnats@gcc.gnu.org
Subject: c++/6730: Crash involving templates when compiling program
Date: Sun, 19 May 2002 22:16:00 -0000	[thread overview]
Message-ID: <200205200510.g4K5AvU02682@tomato.home> (raw)


>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:


             reply	other threads:[~2002-05-20  5:16 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-19 22:16 bbaetz [this message]
2002-05-22  7:08 lerdsuwa

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200205200510.g4K5AvU02682@tomato.home \
    --to=bbaetz@student.usyd.edu.au \
    --cc=gcc-gnats@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).