extern void f(int);
// test(false, true) has UB in C++23, EB in C++26
void test(bool a, bool b) {
unsigned char c;
if (a) {
c = 3;
f(1);
}
if (b) {
f(c);
}
}
However, P2795R3 does say "The automatic storage for an automatic variable is always fully initialized, which has potential performance implications. P2723R1 discusses the costs in some detail." And P2723R1 describes performance costs (and gains!) from initializing bytes, and security concerns about leaking data from stack memory via uninitialized objects and padding bytes.
So I'm not sure: Is it the intent or not that typical-architecture code must do extra initialization of some sort for bytes with erroneous value? Does the draft Standard actually say that? It says each erroneous value "is determined by the implementation independently of the state of the program", but that might have an issue in that the Standard normally prescribes the C++ abstract machine ([intro.abstract]), which doesn't have any equivalent of left-over byte values in the stack influenced by previous program execution.
-- Andrew Schepler