CKTIS / C
volatile — type qualifier
volatile preserves required object accesses but does not provide atomicity or thread synchronization.
Version: C23; repository compiler flag, production runtime not attested
Syntax
volatile int value;
volatile int *pointer_to_volatile;
int * volatile volatile_pointer;volatile qualifies a type. Accesses must respect abstract-machine rules; the implementation defines what constitutes an access. This does not disable all optimization.
volatile int *pointer_to_volatile points to a qualified object; int * volatile volatile_pointer qualifies the pointer itself. Accessing an object defined as volatile through a non-qualified lvalue causes undefined behavior.
volatile provides neither atomicity nor thread synchronization. Threads can work on disjoint sets of objects without explicitly using atomic operations or locks. Standard thread operations can also establish synchronization: a thread’s termination synchronizes with the successful completion of a thrd_join call for that thread.
Examples
#include <stdio.h>
int main(void)
{
volatile int value = 10;
int before = value;
value = 20;
int after = value;
printf("%d %d\n", before, after);
return 0;
}
Result
10 20
The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.