🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.g++.bug
Article #1763

bug in sparc g++ 1.34.1

#1763
From: Tom Quinn
Date: Mon, 20 Mar 1989 16:18
50 lines
2333 bytes
G++ will get a segmentation violation when compiling the following
code with the "-O" option.  This is g++ version 1.34.1 on a Sun4/110
running SunOs 4.0.

Tom Quinn                 Canadian Institute for Theoretical Astrophysics
trq@moose.cita.utoronto.ca
UUCP   - decvax!utgpu!moose!trq
BITNET - quinn@utorphys.bitnet
ARPA   - trq%moose.cita.toronto.edu@relay.cs.net

The compile:
g++ -g -v -O   -c snapcc.cc -o snapcc.o
g++ version 1.34.1
 /usr/local/lib/gcc-cpp -+ -v -undef -D__GNU__ -D__GNUG__ -Dsparc -Dsun -Dunix -D__sparc__ -D__sun__ -D__unix__ -D__OPTIMIZE__ snapcc.cc /tmp/cca18859.cpp
GNU CPP version 1.34
 /usr/local/lib/gcc-c++ /tmp/cca18859.cpp -quiet -dumpbase snapcc.cc -opt -version -G -o /tmp/cca18859.s
GNU C++ version 1.34.1 (sparc) compiled by GNU C version 1.34.
In method void ParticleVec::apply (auto void (*)(struct ParticleRec )):
snapcc.cc:26: Segmentation violation
Program c++ got fatal signal 11.

The code:
------------------------------------------------------------------------
struct ParticleRec {
	double x, y, z, vx, vy, vz;
};
typedef struct ParticleRec Particle;
typedef void (*ParticleProcedure)(Particle );
class ParticleVec 
{
protected:
  int                   len;
  Particle                   *s;                  
                        ParticleVec(int l, Particle* d);
public:
                        ParticleVec ();
                        ParticleVec (int l);
                        ParticleVec (int l, Particle  fill_value);
                        ParticleVec (ParticleVec&);
                        ~ParticleVec ();
  ParticleVec &              operator = (ParticleVec & a);
  Particle&                  operator [] (int n);
  void                  apply(ParticleProcedure f);
};
inline void ParticleVec::apply(ParticleProcedure f)
{
  Particle* top = &(s[len]);
  Particle* t = s;
  while (t < top) (*f)(*t++);
}
Technical Details
Message-ID: <8903201618.AA09449@moose.cita.utoronto.ca>
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!nih-csl!elsie!cvl!haven!purdue!mailrus!tut.cis.ohio-state.edu!MOOSE.CITA.UTORONTO.CA!trq

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!telly!attcan!uunet!nih-csl!elsie!cvl!haven!purdue!mailrus!tut.cis.ohio-state.edu!MOOSE.CITA.UTORONTO.CA!trq
From: trq@MOOSE.CITA.UTORONTO.CA (Tom Quinn)
Newsgroups: gnu.g++.bug
Subject: bug in sparc g++ 1.34.1
Message-ID: <8903201618.AA09449@moose.cita.utoronto.ca>
Date: 20 Mar 89 16:18:36 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 50