There is a code like this:
#include <iostream> int main(){ for(;;){ int* ptr = new (std::nothrow) int; if(ptr == 0){ std::cout << 0 << std::endl; break; } } std::cin.get(); return 0; }
However, this program still throws a std :: bac_alloc exception, although new is called with the std :: nothrow parameter. This program is compiled in Visual C ++ 2010. Why is the exception thrown?
Edit:
Using g ++ on Windows from mingw, everything works fine.
scdmb source share