This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

The exception bug in egcs-970929


This code is miscompiled with -O and dwarf based exception on x86.

# gcc -O des.cc
# a.out
zsh: 26333 segmentation fault  ./a.out

If dwarf based exception is not used, everything is fine. Somehow
g++ adjusts stack twice when calling destructor.

-- 
H.J. Lu (hjl@gnu.ai.mit.edu)
---
class Int 
{
protected:
  int          rep;
public: 
  Int () :rep(0) {}
  Int (const Int& b) :rep(b.Int::val()) {}
  ~Int();
  operator int() const { return val(); }
  int   val() const { return rep; }
  void  operator  = (const int b)
  { rep = b; }
  void  operator ++ ()
  { ++rep; }
};
Int::~Int() {}
void Proc0();
void Proc7(Int IntParI1, Int IntParI2, Int *IntParOut);
main()
{
	Proc0();
	exit(0);
}
void Proc0()
{
	Int		IntLoc1;
	Int		IntLoc2;
	Int		IntLoc3;
	IntLoc1 = 2;
	IntLoc2 = 3;
	while (IntLoc1 < IntLoc2)
	{
		IntLoc3 = 5 * IntLoc1 - IntLoc2;
		Proc7(IntLoc1, IntLoc2, &IntLoc3);
		++IntLoc1;
	}
}
void Proc7(Int IntParI1, Int IntParI2, Int *IntParOut)
{
	Int	IntLoc;
	IntLoc = IntParI1 + 2;
	*IntParOut = IntParI2 + IntLoc;
}


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]