public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Mark Mitchell <mmitchell@usa.net>
To: Joe Buck <jbuck@synopsys.com>, egcs@cygnus.com
Cc: Jason Merrill <jason@cygnus.com>
Subject: Re: internal compiler error in C++ front end
Date: Fri, 03 Oct 1997 10:59:00 -0000	[thread overview]
Message-ID: <199710031800.LAA12697@bmitch.vip.best.com> (raw)

Joe --

>    #include <vector>
>    vector<int> v(3,5);
>
>    I've verified that the crash occurs on both Linux and Solaris/sparc.
>
>    The message is
>
>    /usr/local/egcs/include/g++/vector.h:103: Internal compiler error 97.
>    /usr/local/egcs/include/g++/vector.h:103: Please submit a full bug report
>    to `egcs-bugs@cygnus.com'.

  Sorry it took me so long to get back to you about this.  I've
appended a patch below.  In this case, and in the vector<double> v(3,
5) and vector<double> v(3.0, 3.0) cases below we were (correctly)
using the vector(InputIterator i1, InputIterator i2) constructor, and
blowing up when looking for the nested name iterator_category in the
type int/double, which isn't an aggregate.

  To get the meaning you desire, you have to say:

    vector<int> v((size_t) 3, 5);

  I don't know where this leaves you if you have a vector<size_t>!
  
>    vector<double> v(5, 3.0);
>
>    works fine.
>
>    vector<double> v(3.0, 5);

  Here, we're matching vector<double>::vector(int, double), believe it
or not, so this makes a vector of three elements, each 5.0.

>
>    is quietly accepted, but seems bogus.  I suppose the compiler can
>    assume InputIterator == double, but this seems strange.
>
>    does not crash, but
>
>    vector<double> v(3, 5);
>
>    does: so does the illegal
>    vector<double> v(3.0, 3.0);

-- 
Mark Mitchell		mmitchell@usa.net
Stanford University	http://www.stanford.edu

Fri Oct  3 10:42:37 1997  Mark Mitchell  <mmitchell@usa.net>

	* decl.c (make_typename_type): Do not try to call lookup_field for
	non-aggregate types.

Index: gcc/cp/decl.c
===================================================================
RCS file: /home/mitchell/Repository/egcs/gcc/cp/decl.c,v
retrieving revision 1.1.1.9
diff -c -p -r1.1.1.9 decl.c
*** decl.c	1997/10/02 01:41:35	1.1.1.9
--- decl.c	1997/10/03 17:37:40
*************** make_typename_type (context, name)
*** 4340,4346 ****
    if (! uses_template_parms (context)
        || context == current_class_type)
      {
!       t = lookup_field (context, name, 0, 1);
        if (t == NULL_TREE)
  	{
  	  cp_error ("no type named `%#T' in `%#T'", name, context);
--- 4340,4350 ----
    if (! uses_template_parms (context)
        || context == current_class_type)
      {
!       if (IS_AGGR_TYPE (context))
! 	t = lookup_field (context, name, 0, 1);
!       else
! 	t = NULL_TREE;
! 
        if (t == NULL_TREE)
  	{
  	  cp_error ("no type named `%#T' in `%#T'", name, context);
Index: gcc/testsuite/g++.old-deja/g++.pt/typename3.C
===================================================================
RCS file: typename3.C
diff -N typename3.C
*** /dev/null	Mon Dec 31 20:00:00 1979
--- typename3.C	Fri Oct  3 10:50:29 1997
***************
*** 0 ****
--- 1,17 ----
+ // Build don't link:
+ // GROUPS passed templates
+ template <class T>
+ struct bar { 
+   typedef typename T::baz baz;
+ };
+ 
+ template <class T>
+ void foo(T)
+ {
+   bar<T>::baz(); // ERROR - T is int.
+ }
+ 
+ void foobar()
+ {
+   foo(3);
+ }

             reply	other threads:[~1997-10-03 10:59 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-10-03 10:59 Mark Mitchell [this message]
  -- strict thread matches above, loose matches on Subject: below --
1997-09-29 14:02 Bob Sidebotham
     [not found] <199709282248.PAA07344.cygnus.egcs@atrus.synopsys.com>
1997-09-29  9:40 ` Jason Merrill
1997-09-29 12:35   ` Jan Springer
1997-09-29 15:09   ` Joe Buck
1997-09-29 18:39     ` Jason Merrill
1997-09-28 15:49 Joe Buck
1997-09-29  9:56 ` Mark Mitchell

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=199710031800.LAA12697@bmitch.vip.best.com \
    --to=mmitchell@usa.net \
    --cc=egcs@cygnus.com \
    --cc=jason@cygnus.com \
    --cc=jbuck@synopsys.com \
    /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).