public inbox for gcc-prs@sourceware.org
help / color / mirror / Atom feed
From: Raphael Poss <poss@inf.enst.fr>
To: gcc-gnats@gcc.gnu.org
Cc: regis@enst.fr
Subject: c++/4526: ICE in g++ 3.0.1 when using typeof() as template parameter
Date: Wed, 10 Oct 2001 11:26:00 -0000	[thread overview]
Message-ID: <200110101822.UAA24357@merlin.enst.fr> (raw)

>Number:         4526
>Category:       c++
>Synopsis:       ICE in g++ 3.0.1 when using typeof() as template parameter
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    unassigned
>State:          open
>Class:          ice-on-legal-code
>Submitter-Id:   net
>Arrival-Date:   Wed Oct 10 11:26:01 PDT 2001
>Closed-Date:
>Last-Modified:
>Originator:     
>Release:        3.0.1
>Organization:
ENST
>Environment:
System: SunOS merlin 5.8 Generic_108528-03 sun4u sparc SUNW,Ultra-5_10
Architecture: sun4

	
host: sparc-sun-solaris2.8
build: sparc-sun-solaris2.8
target: sparc-sun-solaris2.8
configured with: ../configure --prefix=~/gcc --enable-languages=c,c++ : (reconfigured) ../configure --prefix=/infres/ir30/infstag/poss/gcc --enable-languages=c,c++
>Description:

G++ 3.0.1 doesn't like the use of typeof() to give a
type parameter to a template structure.

Given the following code:

template<class T>
struct get_begin
{
  typedef typename T::iterator iterator;
  static iterator begin(T& c)
  {
    return c.begin();
  }
};

template<class T>
struct something_t
{
  typedef T some_container;
  void doit(void)
  {
    some_container a;
    typedef get_begin<typeof(a)> my_get_begin; // here is the problem
    typename my_get_begin::iterator i;
  }
};

then G++ 3.0.1 will choke on instanciation of something_t, like in the
following code :

#include <list>

int main(void)
{
 something_t<std::list<int> > something;
}

The error message is :

e.cc: In instantiation of `get_begin<__typeof (a(>':
e.cc:19:   instantiated from here
e.cc:4: Internal error: Segmentation Fault
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL: http://www.gnu.org/software/gcc/bugs.html > for instructions.

>How-To-Repeat:

# 1 "e.cc"
template<class T>
struct get_begin
{
  typedef typename T::iterator iterator;
  static iterator begin(T& c)
  {
    return c.begin();
  }
};

template<class T>
struct something_t
{
  typedef T some_container;
  void doit(void)
  {
    some_container a;
    typedef get_begin<typeof(a)> my_get_begin;
    typename my_get_begin::iterator i;
  }
};

// inclusion of <list> stripped

# 24 "e.cc" 2

int main(void)
{
 something_t<std::list<int> > something;
}

>Fix:

replace
   typedef get_begin<typeof(a)> my_get_begin;
by
   typedef get_begin<some_container> my_get_begin;


>Release-Note:
>Audit-Trail:
>Unformatted:


             reply	other threads:[~2001-10-10 11:26 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-10-10 11:26 Raphael Poss [this message]
2002-05-19  4:01 lerdsuwa
2002-10-31 14:06 Wolfgang Bangerth
2002-11-01 12:06 Wolfgang Bangerth
2002-12-04  4:46 Volker Reichelt

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=200110101822.UAA24357@merlin.enst.fr \
    --to=poss@inf.enst.fr \
    --cc=gcc-gnats@gcc.gnu.org \
    --cc=regis@enst.fr \
    /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).