Article View: gnu.gcc.bug
Article #358Infinite loop compiling attached sample.
From: Keith Dorken
Date: Fri, 10 Apr 1992 17:07
Date: Fri, 10 Apr 1992 17:07
82 lines
2761 bytes
2761 bytes
The GNU 2.1 C++ compiler goes into an infinite loop, and will eventually fill
up my virtual memory (and sometimes kill the machine) on the following program.
It is compiled with
c++ -c -g -v bad.cc
Reading specs from /n/server/usr/local/languages/gnu-compilers/lib/gcc-lib/sun4os4/2.1/specs
gcc version 2.1
/n/server/usr/local/languages/gnu-compilers/lib/gcc-lib/sun4os4/2.1/cpp -lang-c++ -v -undef -D__GNUC__=2 -D__GNUG__=2 -D__cplusplus -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__sparc -D__sun -D__unix -g bad.cc /usr/tmp/cca10268.i
GNU CPP version 2.1 (sparc)
bad.cc contains the line '#include "bad.h"', bad.h contents are at the end of this
message.
This is a fragment of code from a larger class definition; this code used to compile and run with G++ 1.39; I have reduced the code fragement to a small portion. The
problem is around the #ifdef BUG areas of the code fragment. If you remove the
#define BUG, the compiler doesn't loop.
bad.h contains:
#define BUG /* Remove this line to avoid problem. */
typedef struct
{
union
{
unsigned long blo;
unsigned short blos[2]; // for accessing both parts of long
};
unsigned char bhi;
} Bits;
extern Bits* U36_alloc(Bits*, const unsigned long );
extern Bits* U36_alloc_large(Bits*, const unsigned long, const unsigned long );
extern Bits* U36_copy(Bits*, const Bits*);
class Unsigned36
{
protected:
Bits* rep;
public:
Unsigned36();
Unsigned36(const Unsigned36&);
Unsigned36(unsigned long);
Unsigned36(unsigned long, unsigned long); // for those big constants
operator int();
#ifdef BUG
friend int operator == (const Unsigned36&, const Unsigned36&);
#endif
};
typedef Unsigned36 U36; // short form
int operator ! (const Unsigned36& x);
inline Unsigned36::Unsigned36() : rep(U36_alloc(0,0))
{
}
inline Unsigned36::Unsigned36(const Unsigned36& x) : rep(U36_copy(0, x.rep))
{
}
inline Unsigned36::Unsigned36( unsigned long value ) : rep(U36_alloc( 0, value ))
{
}
inline Unsigned36::Unsigned36( unsigned long high, unsigned long low ) : rep( U36_alloc_large(0, high, low))
{
}
inline unsigned int Unsigned36::operator int()
{
return (unsigned int) rep->blo;
}
#ifdef BUG
inline int operator ! ( Unsigned36& x )
{
return( x == 0 );
}
#endif
Technical Details
Message-ID:
<9204101707.AA10273@sabre.Thinkage.On.CA>Path:
arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!thinkage.on.CA!keithShow Full Headers
Complete Article Headers
Newsgroups: gnu.gcc.bug Path: arc1-ca.pugleaf.net!sparky!uunet!cis.ohio-state.edu!thinkage.on.CA!keith From: keith@thinkage.on.CA (Keith Dorken) Subject: Infinite loop compiling attached sample. Message-ID: <9204101707.AA10273@sabre.Thinkage.On.CA> Sender: gnulists@ai.mit.edu Organization: GNUs Not Usenet Distribution: gnu Date: Fri, 10 Apr 1992 17:07:44 GMT Approved: bug-gcc@prep.ai.mit.edu Lines: 95