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]
Other format: [Raw text]

Re: "new" statement and -fno-exceptions


On Oct 4, 2004, at 6:37 AM, Paul Koning wrote:
We recently ran into some problems with an application being killed by
unhandled exception processing -- even though it's compiled
-fno-exceptions.

Ok.


It turns out that a "new" statement will throw an exception on alloc
failure

Yes, it _is_ documented to throw on failure.? If you don't want it to throw either never fail to allocate, or call one that doesn't throw, as documented.? See nothrow_t in the standard.


(if the "nothrow" variant isn't used) no matter whether
-fno-exceptions is used or not.? This is somewhat surprising;

Live and learn I guess.? Next, I suppose you'll be surprised that when you use another C++ library (other than libstdc++) that throws when it is documented to throw, even though you compiled your client code with -fno-exceptions.


-fno-exceptions doesn't change code you call, only your code that you compile.? In your case, you call a routine that throws, and it does; the solution is to stop calling routines that throw.

This is all as designed.


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