Throwing an exception from the destructor of a class is a bad practice because the destructor will be called when an object of that type is alive on the stack and another exception is thrown, which will result in “exception during the exception”. This would terminate the program without any messages.
Instead print the message to the standard error output and call std::abort()
.
This change is part of #26812. It is an improvement on its own, so creating a separate PR for it following the discussion at #32604 (review). Getting it in will reduce the size of #26812.