* BUG: g++ 3.x.x -fomit-frame-pointer: exception handling doesn't work
@ 2004-08-07 14:22 Denis Zaitsev
0 siblings, 0 replies; only message in thread
From: Denis Zaitsev @ 2004-08-07 14:22 UTC (permalink / raw)
To: gcc, linux-gcc
Consider the following example:
#include <stdio.h>
int x(int y)
{
int x= y;
if (y)
printf("%d\n", y);
else
throw "x";
return x;
}
main()
{
try {
x(0);
}
catch (const char *e) {
puts(e);
}
catch (...) {
puts("cathed");
}
}
When compiled without -fomit-frame-pointer, it behaves ok: it prints
'x'. But if compiled with the option, it prints just 'Aborted',
i.e. no exception is catched at all.
A little research shows, that it's stack-related problem (probably,
stack -> dwarf info related): the presence of the printf call in the
x() function makes GCC to allocate the x variable in the 'value'
register, not corrupted by the printf call. It's %ebx here. And so,
GCC does push %ebx in the prologue. And then the exception handling
mechanism dies. If the stack is unmodified at the moment of 'throw
"x"', then the mechanism is ok. This is the case, if the printf call
is removed and the x variable is allocated in a 'cheap' register,
which is not needed to be saved in the stack.
And, finally, as far as I understand, when the frame pointer register
is used, all the stack frame questions are resolved thru it and the
problem described just do not arise.
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2004-08-07 14:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-08-07 14:22 BUG: g++ 3.x.x -fomit-frame-pointer: exception handling doesn't work Denis Zaitsev
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 NNTP newsgroup(s).