fork download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. try {
  6. auto a = new int[1ul<<60];
  7. std::cout << "Allocated at " << std::hex << a << std::endl;
  8. delete[] a;
  9. } catch(const std::bad_alloc&) {
  10. std::cout << "Exception" << std::endl;
  11. }
  12.  
  13. std::cout << "Nothrow: " << new(std::nothrow) int[1ul<<60] << std::endl;
  14.  
  15. auto a = new(std::nothrow) int;
  16. std::cout << "Allocated at " << a << std::endl;
  17. delete a;
  18. return 0;
  19. }
Success #stdin #stdout 0s 80768KB
stdin
Standard input is empty
stdout
Exception
Nothrow: 0
Allocated at 0x2b41080008c0