internal compiler error in C++ front end
Mark Mitchell
mmitchell@usa.net
Fri Oct 3 10:59:00 GMT 1997
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);
+ }
More information about the Gcc
mailing list