File indexing completed on 2026-04-09 07:49:23
0001
0002 #include <climits>
0003 #include <iostream>
0004 #include <new>
0005
0006 int main()
0007 {
0008 std::cout << "[test_catch_throw\n" ;
0009
0010 try
0011 {
0012 int negative = -1;
0013 new int[negative];
0014 }
0015 catch (const std::bad_array_new_length& e)
0016 {
0017 std::cout << "1) " << e.what() << ": negative size\n";
0018 }
0019
0020 try
0021 {
0022 int small = 1;
0023 new int[small]{1,2,3};
0024 }
0025 catch (const std::bad_array_new_length& e)
0026 {
0027 std::cout << "2) " << e.what() << ": too many initializers\n";
0028 }
0029
0030 try
0031 {
0032 long large = LONG_MAX;
0033 new int[large][1000];
0034 }
0035 catch (const std::bad_array_new_length& e)
0036 {
0037 std::cout << "3) " << e.what() << ": too large\n";
0038 }
0039
0040 std::cout << "]test_catch_throw\n" ;
0041
0042 return 0 ;
0043 }
0044
0045