Local static state is internal state held by objects with static storage duration inside a function or local program region. Its persistence matters when function attributes promise reproducible or unsequenced behavior. section 16.3
Apply these rules when annotating functions:
- An [[unsequenced]] function shall not modify local static state, directly or through another function call. section 16.3
- A [[reproducible]] function may modify local static state when that state is not observable outside the function. section 16.3
Caching inside hash
A hash function can memorize results in an internal static table, making repeated calls more efficient while preserving the same visible result. That hidden cache can support [[reproducible]], but the function cannot be [[unsequenced]] because calls must remain properly sequenced. section 16.3
size_t hash(char const[restrict static 32]) [[reproducible]];
Compare the reproducible hash declaration with the hidden-state rule. section 16.3
