Thread View: gnu.g++.bug
1 messages
1 total messages
Started by Tom Quinn
Mon, 20 Mar 1989 16:18
bug in sparc g++ 1.34.1
Author: Tom Quinn
Date: Mon, 20 Mar 1989 16:18
Date: Mon, 20 Mar 1989 16:18
50 lines
2333 bytes
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++);
}
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