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 and exception


On Fri, Jul 12, 2002 at 04:12:01PM -0300, Alexandre Oliva wrote:
> On Jul 12, 2002, "H. J. Lu" <hjl@lucon.org> wrote:
> 
> > When I use -fno-exceptions, I can be prepared to deal any returns from
> > new as long as it doesn't throw an exception
> 
> That's hardly possible, unless you're using new as a shorthand for
> malloc.  new often calls ctors, and there's no way you can interpose a
> NULL-test between the return from operator new and the ctor call.

"no way" ... EXCEPT by calling new (std::nothrow) instead of new, as
he suggested.  Be quite a bit more careful about what you claim is
impossible.

> Besides, if you really mean to do it and modify your program to do so,
> there's no reason for you to not use the nothrow variant of new
> already.

Why should you have to use the nothrow keyword in an exceptionless
program?  Not only is it somewhat inconsistent, it ruins portability
to other exceptionless compilers/systems.


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