Quick A: The behaviour will likely stay the same.
Recently on SO:
With “-fno-exceptions”, what happens with “new T”?
The way I understand it, operator new is defined by libstdc++. If you now compile your own code with -fno-exceptions, you cannot catch any exceptions, but you will still be linking against the normal version of libstdc++, which does throw an exception.
So yes, new T will throw an exception, even with -fno-exception.
However, if you compiled libstdc++ with -fno-exception as well, things become different. Now, new T cannot throw an exception but, if I read the libstdc++ manual right it will call abort() instead.
It seems that, if you want your new T to return NULL on failure, the only way is to explicitely specify nothrow...
Add a Comment
Comments are closed.