From: Denis Zaitsev <zzz@anda.ru>
To: gcc@gcc.gnu.org, linux-gcc@vger.kernel.org
Subject: BUG: g++ 3.x.x -fomit-frame-pointer: exception handling doesn't work
Date: Sat, 7 Aug 2004 20:22:57 +0600 [thread overview]
Message-ID: <20040807202257.A5885@natasha.ward.six> (raw)
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.
reply other threads:[~2004-08-07 14:22 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20040807202257.A5885@natasha.ward.six \
--to=zzz@anda.ru \
--cc=gcc@gcc.gnu.org \
--cc=linux-gcc@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).