🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

compiler bomb

#692
From: Paul Vaughan
Date: Fri, 08 Dec 1989 00:37
106 lines
2742 bytes
The code below causes the compiler (1.36.2) to bomb on a SUN3, I have
no clue why.  This example is derived from some of my code that failed
after adding a virtual base class to what used to be the base class of
the hierarchy.  The really curious thing is that switching the order
of defintion of two functions (both of which have already been
declared) causes the compiler to work as expected.
-----------------------------------

class Base {
public:
  Base() {}
protected:
  Base* base();
private:
  char* name();
};


class VBase : public Base {
public:
  VBase() {}
protected:
  VBase* vbase;
private:
  char* name;
};


class At : public virtual VBase {
public:
  At() { }
protected:
  At* at;
private:
  int n;
};

class FooAt : public At {
public:
  FooAt() {}
protected:
  FooAt* foo;
private:
  int n;
};


class Baz : public virtual VBase {
public:
  Baz() {}
protected:
  Baz* baz;
private:
  int n;
};

class AtBaz : public Baz {
public:
  AtBaz() {}
protected:
  AtBaz* Atbaz;
private:
  int n;
};

class Barf : public AtBaz {
public:
  Barf() {}
protected:
  Barf* barf;
private:
  int n;
};


class BarFooAt : public Barf, public FooAt{
public:
  BarFooAt();
protected:
  BarFooAt* barFooAt;
private:
  int n;
};
BarFooAt* newBarFooAt();

BarFooAt::BarFooAt() {} // if you switch this and the function below, it works fine

BarFooAt* newBarFooAt() {
  return new BarFooAt;   // line 81
}

main() {
}

---------------------------
[1.1475]puma) g++-1.36.2 -v -g -O -DX11  -o vbase vbase.cc -lg++ -llwp -lX11 -lm
g++ version 1.36.2- (based on GCC 1.36)
 /usr/local/gnu/1.36.2/lib/gcc-cpp -+ -v -DX11 -undef -D__GNUC__ -D__GNUG__ -D__cplusplus -Dmc68000 -Dsun -Dunix -D__mc68000__ -D__sun__ -D__unix__ -D__OPTIMIZE__ -D__HAVE_68881__ -Dmc68020 vbase.cc /usr/tmp/cca15245.cpp
GNU CPP version 1.36
 /usr/local/gnu/1.36.2/lib/gcc-cc1plus /usr/tmp/cca15245.cpp -quiet -dumpbase vbase.cc -g -O -version -o /usr/tmp/cca15245.s
GNU C++ version 1.36.2- (based on GCC 1.36) (68k, MIT syntax) compiled by GNU C version 1.36.
default target switches: -m68020 -mc68020 -m68881 -mbitfield
vbase.cc: In function class BarFooAt *newBarFooAt ():
vbase.cc:81: Segmentation violation
g++-1.36.2: Program cc1plus got fatal signal 11.
Technical Details
Message-ID: <8912080037.AA15257@puma.cad.mcc.com>
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!MCC.COM!vaughan%cadillac.cad.mcc.com

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!MCC.COM!vaughan%cadillac.cad.mcc.com
From: vaughan%cadillac.cad.mcc.com@MCC.COM (Paul Vaughan)
Newsgroups: gnu.g++.bug
Subject: compiler bomb
Message-ID: <8912080037.AA15257@puma.cad.mcc.com>
Date: 8 Dec 89 00:37:57 GMT
Sender: daemon@tut.cis.ohio-state.edu
Distribution: gnu
Organization: GNUs Not Usenet
Lines: 106