Thread View: gnu.gcc.bug
1 messages
1 total messages
Started by Gordon Joly
Tue, 26 Jan 1993 02:11
Infinite loop in cc1plus caused by simple code.
Author: Gordon Joly
Date: Tue, 26 Jan 1993 02:11
Date: Tue, 26 Jan 1993 02:11
103 lines
2592 bytes
2592 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
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
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads