Article View: gnu.g++.bug
Article #243g++ 2.1 SEGV/infinite loop
From: Mr I D Redfern
Date: Sat, 11 Apr 1992 18:56
Date: Sat, 11 Apr 1992 18:56
78 lines
3179 bytes
3179 bytes
The following code produces an error message at the line `return s;' followed
by a fatal signal 11 (Segmentation fault) on a Sun4 running SunOS 4.1.2 during
compilation under g++ 2.1. While cutting it down, I discovered that it can
also cause an infinite loop. Cfront 3.0 compiles it without complaint.
---Start
// test.cc (This is -*- C++ -*-)
//#define INF_LOOP
//#define SEGV
class state;
class automaton
{
public:
state new_state();
};
class state
{
automaton& my_aut;
int state_num;
state(const automaton& a, int i);
public:
state(const state& s);
#ifndef INF_LOOP
~state();
#endif
#if defined(SEGV) || defined(INF_LOOP)
operator int() const { return state_num; }
#endif
friend automaton;
};
// Make a new state
state automaton::new_state()
{
state s(*this, 0);
return s;
}
// End.
----End
clover% g++ -v -c -DSEGV test.cc
Reading specs from /usr/local/lib/gnu/gcc-lib/sun4/2.1/specs
gcc version 2.1
/usr/local/lib/gnu/gcc-lib/sun4/2.1/cpp -lang-c++ -v -DSEGV -I/usr/local/lib/g++-include -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix test.cc /usr/tmp/cca16553.i
GNU CPP version 2.1 (sparc)
/usr/local/lib/gnu/gcc-lib/sun4/2.1/cc1plus /usr/tmp/cca16553.i -quiet -dumpbase test.cc -version -o /usr/tmp/cca16553.s
GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
test.cc: In method `class state automaton::new_state ()':
test.cc:35: bad argument 0 for function `state::state (const class state&)' (type was int )
test.cc:35: in conversion to type `state'
/usr/local/bin/gcc: Internal compiler error: program cc1plus got fatal signal 11
clover% g++ -v -c -DINF_LOOP test.cc
Reading specs from /usr/local/lib/gnu/gcc-lib/sun4/2.1/specs
gcc version 2.1
/usr/local/lib/gnu/gcc-lib/sun4/2.1/cpp -lang-c++ -v -DINF_LOOP -I/usr/local/lib/g++-include -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix test.cc /usr/tmp/cca16560.i
GNU CPP version 2.1 (sparc)
/usr/local/lib/gnu/gcc-lib/sun4/2.1/cc1plus /usr/tmp/cca16560.i -quiet -dumpbase test.cc -version -o /usr/tmp/cca16560.s
GNU C++ version 2.1 (sparc) compiled by GNU C version 2.1.
test.cc: In method `class state automaton::new_state ()':
test.cc:35: bad argument 0 for function `state::state (const class state&)' (type was int )
test.cc:35: in conversion to type `state'
test.cc:35: bad argument 0 for function `state::state (const class state&)' (type was int )
test.cc:35: in conversion to type `state'
... and repeats
If you need any more information, please let me know.
Thanks,
Ian Redfern (marab@dcs.warwick.ac.uk)
Technical Details
Message-ID:
<xmmhb98s@csv.warwick.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!warwick.ac.UK!marabShow Full Headers
Complete Article Headers
Newsgroups: gnu.g++.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!warwick.ac.UK!marab From: marab@warwick.ac.UK (Mr I D Redfern) Subject: g++ 2.1 SEGV/infinite loop Message-ID: <xmmhb98s@csv.warwick.ac.uk> Sender: gnulists@ai.mit.edu Organization: Computing Services, Warwick University, UK Distribution: gnu Date: Sat, 11 Apr 1992 18:56:03 GMT Approved: bug-g++@prep.ai.mit.edu Lines: 79