2.1.51. --[no_]force_new_nothrow

This option controls the behavior of new expressions in C++.

The C++ standard states that only a no throw operator new, one that is declared with throw, is permitted to return NULL on failure. Any other operator new is never permitted to return NULL and the default operator new throws an exception on failure.

If you use --force_new_nothrow, the compiler treats expressions such as new T(...args...), that use the global ::operator new or ::operator new[], as if they are new (std::nothrow) T(...args...).

--force_new_nothrow also causes any class-specific operator new or any overloaded global operator new to be treated as no throw.


The option --force_new_nothrow is provided only as a migration aid for legacy source code that does not conform to the C++ standard. Its use is not recommended.


This option is effective only if the source language is C++.


The default is --no_force_new_nothrow.


struct S
    void* operator new(std::size_t);
    void* operator new[](std::size_t);
void *operator new(std::size_t, int);

With the --force_new_nothrow option in effect, this is treated as:

struct S
    void* operator new(std::size_t) throw();
    void* operator new[](std::size_t) throw();
void *operator new(std::size_t, int) throw();

See also

Copyright © 2007, 2010 ARM Limited. All rights reserved.ARM DUI 0348A