public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: Re: g++ & non-call-exceptions & sigsetjmp
@ 2004-03-24 15:34 Eljay Love-Jensen
  0 siblings, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2004-03-24 15:34 UTC (permalink / raw)
  To: Devrat Mittal, gcc-help

Hi Devrat,

Your code sort-of worked for me.  Red Hat Linux Advanced Server 2.1, using 
GCC 3.2.

C++ exceptions and setjmp/longjmp do not interact well.  Likewise, I 
suspect that C++ exceptions and sigsetjmp also do not interact well.

I recommend avoiding a throw from within the context of a signal handler.

HTH,
--Eljay

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

* Re: Re: g++ & non-call-exceptions & sigsetjmp
@ 2004-03-24 20:14 Eljay Love-Jensen
  0 siblings, 0 replies; 3+ messages in thread
From: Eljay Love-Jensen @ 2004-03-24 20:14 UTC (permalink / raw)
  To: Devrat Mittal, gcc-help

Hi Devrat,

I do not know why the sigsetjmp is required to get the throw to be recognized.

Note, with -O1 it works.

But with -O2 or -O3 it fails.

Sorry,
--Eljay

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

* Re: Re: g++ & non-call-exceptions & sigsetjmp
@ 2004-03-24 15:31 Devrat Mittal
  0 siblings, 0 replies; 3+ messages in thread
From: Devrat Mittal @ 2004-03-24 15:31 UTC (permalink / raw)
  To: eljay, gcc-help

On Wed, 24 Mar 2004, Eljay Love-Jensen wrote:

> Hi Devrat,
> 
> I believe it is impossible to throw out of a signal handler.  Or out of any 
> kind of callback (e.g., X11).  Any exception that hits a C-barrier will 
> terminate the application.
> 
> You'll have to figure out a different mechanism to detect the signal 
> condition in your program.  Perhaps by setting a volatile global variable 
> within the signal handler, and checking that global at opportune times in 
> your regular code.
> 
> HTH,
> --Eljay
> 
Hi eljay,
	But guy, I said I compiled that code already with a throw inside 
of the exception handler. The compile command was given as follows:
	g++ test.c -g -Wall -fnon-call-exceptions
What I am looking forward to is this:
	Java generates for example some kind of arithmetic exceptions when 
say "division by zero" happens in the program. Now in C++, such an 
exception cannot be caught in "catch" blocks. Such exceptions
can only be caught inside of signal handlers. 
	So we can just throw from within the signal handler as the program 
i enclosed in the post does & catch it from main (which again the program 
is able to.). 
	The code works fine on my Redhat 8.0 linux box & surely does 
convince me that exceptions can be thrown from signal handlers & still be 
caught elsewhere in the code.
	If you dont mind, plz run the program & see what happens.(under 
g++ with the options -fnon-call-exceptions). I really would like to know 
ur comments after the run.
Thanks,

regards
-- 
Devrat Mittal
M.tech 2nd year
Roll no. 2002301





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

end of thread, other threads:[~2004-03-24 15:31 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-03-24 15:34 Re: g++ & non-call-exceptions & sigsetjmp Eljay Love-Jensen
  -- strict thread matches above, loose matches on Subject: below --
2004-03-24 20:14 Eljay Love-Jensen
2004-03-24 15:31 Devrat Mittal

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