Hi,
Thanks for this simple solution.
Yet, why isn't this the default when using -fno-exceptions ?
Christophe.
On 27.09.2007 15:31, Richard Li wrote:
Hi,
I tried to redefine the global "new" operator like the following code,
and it seems to work.
#include <new>
void * operator new (size_t n)
{
return operator new (n, std::nothrow);
}
void * operator new [] (size_t n)
{
return operator new [] (n, std::nothrow);
}
On 9/27/07, Christophe LYON <christophe.lyon@xxxxxx> wrote:
Hello,
I am compiling a C++ application, which uses the 'new' operator, with
exceptions disabled (-fno-exceptions).
Yet, the new operator called is the one that throws an exception in case
of failure. Why is it so ? Isn't it inconsistent with the
-fno-exceptions flag?
I imagined that compiling with -fno-exceptions would make the compiler
generate calls to new(nothrow) instead.
In my case, replacing all calls to new to new(nothrow) in the
application is not an option.
Thanks,
Christophe.