Why no exception | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Why no exception

Hi I am doing so many allocation in for loop, but it is still not throwing exception. I just need to ovserve bad_alloc throw and was expecting this code to crash due to non handled exception. When does sololearn not allocate heap memory ? https://code.sololearn.com/cFpAO3jJGD8V/?ref=app

10th Jan 2023, 8:47 AM
Ketan Lalcheta
Ketan Lalcheta - avatar
2 Answers
+ 3
Allocations are fine. Instead try: p = new int[10000000000]; //for exception.
10th Jan 2023, 10:32 AM
Jayakrishna 🇮🇳
+ 2
Thanks... basically this platform handles int_max allocation... just tried with your value and it worked. Modified code with long_max/10 as long_max was giving issue. Thank you so much
10th Jan 2023, 10:46 AM
Ketan Lalcheta
Ketan Lalcheta - avatar