liveBook · Manning

Volatile qualification

Volatile qualification is a type qualifier that tells the compiler accesses to an object may have observable effects and must not be freely eliminated or optimized as ordinary accesses.

How 2 Manning books explain it

Modern C, Third Edition

The C volatile qualifier specifies that accesses to an object may have externally observable effects and must not be treated as freely eliminable or cacheable by the compiler.

How it is used
Preserves necessary object accesses during optimization in measurements, long-jump recovery, and signal handling.
How deep it goes
Explains reloads and stores, then traces optimization consequences through assembly and exceptional control flow; distinguishes volatile access from uninterruptible operations.
Examples
Compares timed C loops and GCC and Clang assembly, then uses a volatile depth variable in a setjmp and longjmp example.
What you can do after
Diagnose/debug with it when optimization discards measurement work or makes assumptions about values changed across unusual control flow.

Read how Modern C, Third Edition explains volatile qualification →

Modern C

A volatile qualification is a C type qualifier indicating that an object's value may change independently of ordinary program execution and must not be optimized away from accesses.

How it is used
Preserves required object accesses in measurement loops and values used after setjmp/longjmp.
How deep it goes
Explains reloads, stores, and optimization costs through loop assembly and a longjmp repair; does not develop a general concurrency model.
Examples
Compares three timed loops and repairs a parser's nesting-depth diagnostic after longjmp.
What you can do after
Diagnose/debug with it an eliminated measurement loop or an incorrect value used after longjmp.

Read how Modern C explains volatile qualification →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.