public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Use of -fno-exceptions
@ 2001-11-07 14:25 Ian Cottam
  2001-11-07 17:18 ` Joe Buck
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Cottam @ 2001-11-07 14:25 UTC (permalink / raw)
  To: gcc

We use gcc 2.95.3.
To save space in our very large build we use  -fno-exceptions.
Now, a colleague says he needs exceptions in one, localized class. Is it
safe to just compile this class/file (but no other) with the
default -fexceptions ?
Thanks for any help.
-Ian
Ian Cottam


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

* Re: Use of -fno-exceptions
  2001-11-07 14:25 Use of -fno-exceptions Ian Cottam
@ 2001-11-07 17:18 ` Joe Buck
  2001-11-08  5:13   ` Jeff Sturm
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Buck @ 2001-11-07 17:18 UTC (permalink / raw)
  To: ian; +Cc: gcc


> We use gcc 2.95.3.
> To save space in our very large build we use  -fno-exceptions.
> Now, a colleague says he needs exceptions in one, localized class. Is it
> safe to just compile this class/file (but no other) with the
> default -fexceptions ?

The exceptions support is needed to do a cleanup.  When an exception
is thrown, the stack gets popped one frame at a time and destructors
are called, up to the point where the exception is caught.  For this
to work properly, every possible call site that could be involved
would need to be compiled with exceptions enabled.  You may be able
to make a mixed environment work, but it will be tricky and perhaps
unstable.

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

* Re: Use of -fno-exceptions
  2001-11-07 17:18 ` Joe Buck
@ 2001-11-08  5:13   ` Jeff Sturm
  2001-11-08  9:00     ` Joe Buck
  0 siblings, 1 reply; 5+ messages in thread
From: Jeff Sturm @ 2001-11-08  5:13 UTC (permalink / raw)
  To: Joe Buck; +Cc: ian, gcc



On Mon, 19 Nov 2001, Joe Buck wrote:
> > We use gcc 2.95.3.
> > To save space in our very large build we use  -fno-exceptions.
> > Now, a colleague says he needs exceptions in one, localized class. Is it
> > safe to just compile this class/file (but no other) with the
> > default -fexceptions ?
> 
> The exceptions support is needed to do a cleanup.  When an exception
> is thrown, the stack gets popped one frame at a time and destructors
> are called, up to the point where the exception is caught.  For this
> to work properly, every possible call site that could be involved
> would need to be compiled with exceptions enabled.  You may be able
> to make a mixed environment work, but it will be tricky and perhaps
> unstable.

Is that strictly true?  My understanding is that one could use
sjlj-exceptions and throw over any call frame, compiled with -fexceptions
or not, because setjmp/longjmp processing doesn't require explicit unwind
info.

For the default EH model, your statement above is correct.

Jeff

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

* Re: Use of -fno-exceptions
  2001-11-08  5:13   ` Jeff Sturm
@ 2001-11-08  9:00     ` Joe Buck
  2001-11-08 11:26       ` Jeff Sturm
  0 siblings, 1 reply; 5+ messages in thread
From: Joe Buck @ 2001-11-08  9:00 UTC (permalink / raw)
  To: Jeff Sturm; +Cc: Joe Buck, ian, gcc


> > The exceptions support is needed to do a cleanup.  When an exception
> > is thrown, the stack gets popped one frame at a time and destructors
> > are called, up to the point where the exception is caught.  For this
> > to work properly, every possible call site that could be involved
> > would need to be compiled with exceptions enabled.  You may be able
> > to make a mixed environment work, but it will be tricky and perhaps
> > unstable.
> 
> Is that strictly true?  My understanding is that one could use
> sjlj-exceptions and throw over any call frame, compiled with -fexceptions
> or not, because setjmp/longjmp processing doesn't require explicit unwind
> info.

For a call frame where a destructor must be called, even with sjlj you
need -fexceptions to get that destructor called.  Otherwise there will
be a memory leak and possibly some resource that should be freed won't
be (like a lock for a critical region, if managed with a constructor/
destructor pair).

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

* Re: Use of -fno-exceptions
  2001-11-08  9:00     ` Joe Buck
@ 2001-11-08 11:26       ` Jeff Sturm
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Sturm @ 2001-11-08 11:26 UTC (permalink / raw)
  To: Joe Buck; +Cc: ian, gcc



On Mon, 19 Nov 2001, Joe Buck wrote:
> > > The exceptions support is needed to do a cleanup.  When an exception
> > > is thrown, the stack gets popped one frame at a time and destructors
> > > are called, up to the point where the exception is caught.  For this
> > > to work properly, every possible call site that could be involved
> > > would need to be compiled with exceptions enabled.  You may be able
> > > to make a mixed environment work, but it will be tricky and perhaps
> > > unstable.
> > 
> > Is that strictly true?  My understanding is that one could use
> > sjlj-exceptions and throw over any call frame, compiled with -fexceptions
> > or not, because setjmp/longjmp processing doesn't require explicit unwind
> > info.
> 
> For a call frame where a destructor must be called, even with sjlj you
> need -fexceptions to get that destructor called.  Otherwise there will
> be a memory leak and possibly some resource that should be freed won't
> be (like a lock for a critical region, if managed with a constructor/
> destructor pair).

You're right.  I was thinking about the common case in which I have a C
library compiled without -fexceptions.  Since C doesn't have destructors,
I can get by with sjlj-exceptions.

Jeff

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

end of thread, other threads:[~2001-11-19 19:40 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-07 14:25 Use of -fno-exceptions Ian Cottam
2001-11-07 17:18 ` Joe Buck
2001-11-08  5:13   ` Jeff Sturm
2001-11-08  9:00     ` Joe Buck
2001-11-08 11:26       ` Jeff Sturm

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