This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

std::nothrow

Is the std::nothrow supported by the compiler in the constructor list?

m_inQueueBuffer(new (std::nothrow) U32*[m_sTOTAL_CMD_QUEUE_SIZE]),

It compiles, but what will it do if no memory can be allocated?  What happens when this pointer is dereferenced?

  • std::nothrow means that in the event the memory cannot be allocated, operator new will return NULL instead of throwing an exception.

    If you dereference any NULL pointer, you get undefined behavior, which means you can get anything from the program behaving as you expect to melting your hard drive.  Most likely the program will just crash.

    In summary, if you use new nothrow, you are responsible for checking the return value.