C++ compiler -- does it work?

New Message Reply Date view Thread view Subject view Author view

Michael J. Smith (smith++at++vsl.ist.ucf.edu)
Mon, 23 Jan 1995 19:26:25 -0500 (EST)


Ok, I know this may be somewhat unrelated to the main focus of this
group, but when I compiled some code under 5.3, I got a cool little
segment fault. I managed to write a small program that produces this
fault and it boils down to a static variable inside a method call.

Is this not supported by the C++ language? Here's the code

--------------------------------------------
class crash
{
 public:
  crash() {}
  ~crash() {}
  void crashit();
};

void crash::crashit()
{
  static crash tq; // comment out this line and it doesn't crash
// crash tq; // with this line it doesn't crash...
}

void main()
{
  crash q1, q2;
}

// Compile this program with CC crash.C
// run a.out and see a nice seg fault on IRIX5.3 -- dbx says
// Core from signal SIGSEGV: Segmentation violation
//(dbx) > 0 _fini(0x400c2c, 0x0, 0x0, 0x0)
// ["../patch/c++init.c++":76, 0x400c60]
// 1 <stripped>() [<stripped>, 0xfb6b3d4]
//
----------------------------------------------

If anyone can explain this I'd love to hear it. I suppose I can use
another technique, but this exact code will run without any problems on
any of the eariler compilers...

Any answers are welcomed....

-----------------------------------------------------------------------------
| Michael J. Smith University Of Central Florida |
| Visual Systems Laboratory Institute for Simulation & Training |
| Graduate Research Assistant 3280 Progress Drive |
| smith++at++vsl.ist.ucf.edu Orlando, FL 32826-0544 |
| ++at++cs.ucf.edu |
-----------------------------------------------------------------------------


New Message Reply Date view Thread view Subject view Author view

This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:50:53 PDT

This message has been cleansed for anti-spam protection. Replace '++at++' in any mail addresses with the '@' symbol.