public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* The exception bug in egcs-970929
@ 1997-10-01 14:33 H.J. Lu
  1997-10-07  3:48 ` Andreas Schwab
  0 siblings, 1 reply; 2+ messages in thread
From: H.J. Lu @ 1997-10-01 14:33 UTC (permalink / raw)
  To: egcs

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;
}

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: The exception bug in egcs-970929
  1997-10-01 14:33 The exception bug in egcs-970929 H.J. Lu
@ 1997-10-07  3:48 ` Andreas Schwab
  0 siblings, 0 replies; 2+ messages in thread
From: Andreas Schwab @ 1997-10-07  3:48 UTC (permalink / raw)
  To: H.J. Lu; +Cc: egcs

H J Lu <hjl@lucon.org> writes:

|> 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.

I have just sent this to Kenner for gcc2:

The FDE insns that belong to a specific pc value always come after a
DW_CFA_advance_loc that advances to that pc value.  Thus when
__frame_state_for executes the FDE insns it must still do that if the
current pc value equals the target pc value.

1997-10-04  Andreas Schwab  <schwab@issan.informatik.uni-dortmund.de>

	* frame.c (__frame_state_for): Execute the FDE insns until the
	current pc value is strictly bigger than the target pc value.

*** testgcc-970926/frame.c.~1~	Wed Sep 24 23:05:26 1997
--- testgcc-970926/frame.c	Sat Oct  4 18:43:39 1997
*************** __frame_state_for (void *pc_target, stru
*** 600,606 ****
    /* Then the insns in the FDE up to our target PC.  */
    end = next_fde (f);
    pc = f->pc_begin;
!   while (insn < end && pc < pc_target)
      insn = execute_cfa_insn (insn, &state, &info, &pc);
  
    memcpy (state_in, &state.s, sizeof (state.s));
--- 600,606 ----
    /* Then the insns in the FDE up to our target PC.  */
    end = next_fde (f);
    pc = f->pc_begin;
!   while (insn < end && pc <= pc_target)
      insn = execute_cfa_insn (insn, &state, &info, &pc);
  
    memcpy (state_in, &state.s, sizeof (state.s));

-- 
Andreas Schwab                                      "And now for something
schwab@issan.informatik.uni-dortmund.de              completely different"

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~1997-10-07  3:48 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-10-01 14:33 The exception bug in egcs-970929 H.J. Lu
1997-10-07  3:48 ` Andreas Schwab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).