C++ Logo


Advanced search

[ub] Diagnosis of implementation limits

From: David Krauss <david_work_at_[hidden]>
Date: Thu, 23 Jan 2014 10:22:01 +0800
Migrating this from the std-discussion list; itís more appropriate here.

On Thursday, January 23, 2014 9:15:41 AM UTC+8, Richard Smith wrote:
On Tue, Jan 7, 2014 at 1:39 AM, David Krauss <pot..._at_[hidden]> wrote:
There are no requirements about what happens when these resource limits are exceeded.

This is the intent, and is deliberate. If you run your compiler out of memory or stack space, or otherwise exceed its limits in a way which it might not be able to defend against, it is not required to produce a diagnostic.

If a program is abnormally terminated, most environments emit a message which counts toward the diagnostic requirement. An OS/shell which doesn't, or which allows the stack to overflow into the heap, is unsuitable for development work.

Running out of heap space may be diagnosed by the usual means: std::bad_alloc, check for null pointer results.

Internal buffer overflows related to hard-coded limits can and should always be caught.

Moreover there's no excuse for generating and executing a defective program.

In a strict sense, exceeded limits incurring UB seems to negate any guarantee that C++ can express a nontrivial program.

Received on 2014-01-23 03:22:14