🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.bug
Article #218

g++ bug report

#218
From: Russel Winder
Date: Tue, 07 Apr 1992 18:17
110 lines
2909 bytes
Attached are two strip-down programs highlighting at least 2 bugs in g++
2.1.

The first indicates a problem with const member function in templates.
In my more complicated original I got internal compiler
error on signal 11 type problems.  In the stripped down I got the
message:

> g++ trial.cc
> trial.cc: In function `int  main ()':
> trial.cc:18: template for method `Y' doesn't match any in class `X<int>'
> 
> Compilation exited abnormally with code 1 at Tue Apr  7 16:58:36

The second problem, I have been unable to get beyond the error message:

> g++ trial_2.cc
> /cs/research/coside/users/croissant/russel/local/bin/gcc: Internal
compiler error: program cc1plus got fatal signal 11
> 
> Compilation exited abnormally with code 1 at Tue Apr  7 17:07:03

In the time available.  

I am told that GCC was configured by issuing:

./configure --target=space-sun-sunos4.1

Russel.

==========================================================================

Dr Russel Winder		(InterNet: R.Winder@cs.ucl.ac.uk)
Department of Computer Science	(UUCP: {...mcsun!ukc!}ucl-cs!R.Winder)
University College London	(JANet: R.Winder@uk.ac.ucl.cs)
Gower Street
London WC1E 6BT
England

Phone: +44 (0)71 380 7293
Fax: +44 (0)71 387 1397

=========================================================================

//  This program should give the error message since the types are
//  wrong, it compiles and runs.  Putting the const in the class
//  declaration to correct things causes the error.

#include <iostream.h>

template <class T>
class W
{
public:
    void Y() const // Inlining presents no problems at all.
    {
	cout << "Executing W<T>::Y\n" ;
    }
} ;

template <class T>
class X
{
public:
    void Y() ; // put const here and everything falls apart...
} ;

template <class T>
void X<T>::Y() const // ... because this const appears to be ignored!
{
    cout << "Executing X<T>::Y\n" ;
}

main()
{
    W<int> z0 ;
    z0.Y() ;
    X<int> z1 ;
    z1.Y() ;
}

=======================================================================

//  Some complexity in the template generation causes an internal compiler error.

#include <iostream.h>

template <class T>
class X
{
public:
    void Y() ;
} ;

template <class T>
void X<T>::Y()
{
    cout << "Executing X<T>::Y\n" ;
}

template <class T>
ostream& operator << (ostream& os, X<T> s)
{
    return os ;
}

main()
{
    X<int> z1 ; // compiles perfectly without this line!
}
Technical Details
Message-ID: <9204071619.AA27139@life.ai.mit.edu>
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.ucl.ac.uk!R.Winder

Show Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug
Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!cs.ucl.ac.uk!R.Winder
From: R.Winder@cs.ucl.ac.uk (Russel Winder)
Subject: g++ bug report
Message-ID: <9204071619.AA27139@life.ai.mit.edu>
Sender: gnulists@ai.mit.edu
Organization: GNUs Not Usenet
Distribution: gnu
Date: Tue, 7 Apr 1992 18:17:52 GMT
Approved: bug-gcc@prep.ai.mit.edu
Lines: 111