This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: -fno-exceptions and bad_alloc


> Date: Tue, 28 Sep 1999 20:27:54 +0200
> From: Andi Kleen <ak@muc.de>

> On Tue, Sep 28, 1999 at 09:45:43PM +0200, Mike Stump wrote:
> > > > Use new (nothrow).
> > 
> > > Shouldn't this be the default for new when -fno-exceptions is enabled?
> > 
> > No.

> Hmm. I just did a small experiment (trying to throw across a module
> with compiled with -fno-exceptions), and it core dumped on my Linux box.

> So you feel happy with adding the sentence "When a new in C++ fails
> the program will crash unless you're using sjlj exceptions" to the
> -fno-exceptions documentation?

Yes.

Throwing into code compiled without exception handling support, is
undefined.  Don't do that.  It is up to the user to know if a routine
will throw or not, and to protect themselves from throws, or otherwise
ensure the code won't throw.

new, is documented as throwing.  new (nothrow) is documented as not
throwing.  For library code, see the documentation on wether it can
throw or not, or under what conditions it will throw.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]