Article View: gnu.gcc.bug
Article #1655Internal error in cc1plus (signal 4) - simple string class example.
From: Gordon Joly
Date: Tue, 26 Jan 1993 02:14
Date: Tue, 26 Jan 1993 02:14
114 lines
2827 bytes
2827 bytes
On a SUN4, SunOS 4.1.1, gcc 2.3.3 (built with 2.3.1) libg++ 2.3, & SUN
libc.so.1.6.1
#include<iostream.h>
#include<String.h>
// A very simple class consisiting of a String, int pair
class Collection
{
String name;
int id_number;
public:
Collection(String& s, int p):name(s),id_number(p){}
// constructor does nothing exciting
operator String(){return name;}
// conversion operator similarly dull
ostream& print(ostream& a)
{
a<<"name: "<<name<<"\n"
<<"id_number: "<<id_number<<"\n";
return a;
}
// output
String& GetName()
{
return name;
}
// .. and access
};
// a trivial example function ... but could just as well have been
// a class member function for this problem
void DoSomething(String& s)
{
cout<<"ya boo sucks: "<<s<<"\n";
}
int main()
{
Collection guanaco("llama", 42);
// DoSomething(guanaco.GetName()); // This works fine
DoSomething(guanaco); // Compiler never exits...
guanaco.print(cout)<<"\n";
return 0;
}
/*
-----------------------------------------------------
Above is an example of code that compiles without error on the
departmental compiler and causes 2.3.3 to hang.
NB 2.3.3 copes if the commented DoSomething() invocation is used
instead.
I think there may be some other bugs in the error recovery department
i.e. a parse error gets reported sometimes and the compiler hangs. But
I will try to provide a separate example of this.
D.Critchley
-------------------------------------------------------------
*/
Runs with output:
porridge:gjoly/c++/2.x[76] a.out
ya boo sucks: llama
name: llama
id_number: 42
porridge:gjoly/c++/2.x[77]
Snapshot with "error"
PID USERNAME PRI NICE SIZE RES STATE TIME WCPU CPU COMMAND
9845 gjoly 82 0 32424K 14256K run 1:17 74.04% 73.83% cc1plus
Followed by
porridge:gjoly/c++/2.x[79]
/cs/research/coside/local/croissant/bin/gcc: Internal compiler
error: program cc1plus got fatal signal 4
porridge:gjoly/c++/2.x[79]
porridge:gjoly/c++/2.x[79]
Gordon.
Gordon Joly Phone +44 71 387 7050 ext 3703 FAX +44 71 387 1397
Internet: G.Joly@cs.ucl.ac.uk UUCP: ...!{uunet,uknet}!ucl-cs!G.Joly
Computer Science, University College London, Gower Street, LONDON WC1E 6BT
Technical Details
Message-ID:
<9301251819.AA08523@life.ai.mit.edu>Path:
arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cs.ucl.ac.uk!G.JolyShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!cis.ohio-state.edu!cs.ucl.ac.uk!G.Joly From: G.Joly@cs.ucl.ac.uk (Gordon Joly) Newsgroups: gnu.gcc.bug Subject: Internal error in cc1plus (signal 4) - simple string class example. Date: 25 Jan 1993 21:14:15 -0500 Organization: GNUs Not Usenet Lines: 116 Sender: daemon@cis.ohio-state.edu Approved: bug-gcc@prep.ai.mit.edu Distribution: gnu Message-ID: <9301251819.AA08523@life.ai.mit.edu>