C++ Logo

std-proposals

Advanced search

Re: [std-proposals] noexcept(static)

From: Rainer Deyke <rainerd_at_[hidden]>
Date: Tue, 3 Nov 2026 19:48:55 +0100
On 11/3/26 18:32, Sebastian Wittmeier via Std-Proposals wrote:
> 1b) The correct image size was the responsibility of the caller. The decoder still checked the precondition and found an error.

If it's a true precondition failure, then it's too late to do anything
about it, so the decoder might as well not bother. Precondition
violation = undefined behavior = the program is no longer in a valid
state. If the caller wants a safety check on the image size, the place
for that check is in a wrapper around the function, not inside it.

Conversely, if the decoder checks the image size and reports an error
back to the caller in a form that the caller can use, then this is not a
true precondition failure. It's an expected error path that should be
defined, documented and tested.

> 2b) The correct image size is not known beforehand, but the overall system development group/team should have made sure that only working images are loaded. So it is neither the responsibility of the caller, nor the callee, but of the organisation.

The program should not make assumptions about its environment (beyond
"the CPU is working" and "memory bits don't flip randomly"). Correctly
sized externally stored images can and should be checked, ideally before
the plane takes off.


-- 
Rainer Deyke - rainerd_at_[hidden]

Received on 2026-11-03 18:49:08