C++ exceptions and memory allocation failure -- Wu Yongwei
C++ exceptions are habitually disabled in many software projects. A related issue is that these projects also encourage the use of new (nothrow) for fear of exceptions. Is it good practice or bad practice? Also, how likely are we to really encounter out-of-memory errors? I will investigate on this topic and discuss strategies to deal with memory issues.
C++ Exceptions and Memory Allocation Failure
By Wu Yongwei
From the article:
In fact, every time we initialize or modify a
string,vector, ormap, we may be allocating memory on the heap. If we think thatnewwill end in an exception (and therefore choose to usenew (nothrow)), exceptions may also occur when using these mechanisms. In a program that has disabled exceptions, the result will inevitably be a program crash.Ignoring abnormal scenarios like allocating more memory than the physical memory size at a time (which would likely be a logic error in the program), can a reasonable program still experience memory allocation failures?

In this article, we are going to review two new features of C++23. Now the language allows the call operator (
The Curiously Recurring Template Pattern (CRTP) is a heavily used idiom in C++. It is similarly resistant to understanding as the classic design pattern visitor I presented in my last post: “
Some time ago I started working on P1705 Enumerating Core Undefined Behavior, I have collected a large set of undefined behavior (UB) during that time. There is going to be a lot of work involved in getting the annex into shape and editing it into the standard. While this work is ongoing, I will take some time to write blog posts to explore the set of undefined behaviors.