8.82 --force_new_nothrow, --no_force_new_nothrow

Controls the behavior of new expressions in C++.

The C++ standard states that only a no throw operator new 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.

Note

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

Mode

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

Default

The default is --no_force_new_nothrow.

Examples

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();
Related reference
11.5 Using the ::operator new function in ARM C++
Non-ConfidentialPDF file icon PDF versionARM DUI0472J
Copyright © 2010-2013 ARM. All rights reserved.