With "-fno-exceptions", what happens with "new T"?

c++, exception

Solution

I can't give a definitive answer to all the perks around -fno-exceptions, just the observations on a 32 bit linux machine, gcc 4.5.1 - bad_alloc is thrown with and without `-fno-exceptions`

[21:38:35 1 ~/tmp] $ cat bad_alloc.cpp

int main()
{
    char* c = new char[4000000000U];
}
[21:38:58 1 ~/tmp] $ g++ bad_alloc.cpp
[21:39:06 1 ~/tmp] $ ./a.out
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted
[21:39:07 1 ~/tmp] $ g++ -fno-exceptions bad_alloc.cpp
[21:39:16 1 ~/tmp] $ ./a.out
terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted

Problem

I was wondering, will `new T` still throw `bad_alloc` if I compile my program using the `-fno-exceptions` option to disable exception handling? Or will the compiler (GCC and clang support that option) implicitly transform the use of `new T` to `new (nothrow) T`?

Original source

Related problems