CKTIS / C
register — storage-class specifier
register suggests fast access but does not guarantee a CPU register. It also restricts taking an object's address.
Version: C23; repository compiler flag, production runtime not attested
Syntax
register int counter = 0;register remains a storage-class specifier in C23. It can be used for block-scope objects and function parameters; they have automatic storage duration.
It suggests fast access but guarantees neither a CPU register nor a speedup. The suggestion's effectiveness is implementation-defined. You cannot take such an object's address with &, even when the compiler ignores the suggestion.
Converting an array declared with register to a pointer causes undefined behavior; this includes ordinary subscripting. The example uses scalars: it adds 1 through 4 and prints 10.
Examples
#include <stdio.h>
int main(void)
{
register int total = 0;
for (register int i = 1; i <= 4; ++i) {
total += i;
}
printf("%d\n", total);
return 0;
}
Result
10
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.