~/talk

What Volatile Means (and Doesn’t Mean) in C++ Programming

Talkat CppCon 2024 · on Monday, 2024-09-16· at 11:00· Cottonwood 2/3, 6700 North Gaylord Rockies Boulevard· [security]
name:Ben Saks
links:none on file
slides:none on file

Explains that volatile protects accesses to memory-mapped UART registers (status bit and transmit buffer) by preventing the compiler from eliding or reordering those accesses, but it does not make accesses atomic nor serve as a general threading primitive. Demonstrates a real UART busy‑wait that fails without volatile, shows workaround of non‑inline read/write wrappers plus use of -O0 or pragmas, cites a 2008 paper testing 13 compilers that found miscompilations, and recommends noinline wrappers and memory barriers.

AI-written summary · about

  1. 0:00Intro
  2. 0:36What is Volatile
  3. 3:24Device Registers
  4. 7:14Side Effects
  5. 11:10What Can We Do
  6. 14:19Declaration Specifiers
  7. 17:51East Volatile Style
  8. 20:29Volatile Protections
  9. 22:35Volatile Dis
  10. 28:49Volatile Compiler Bugs
  11. 31:31How to Disable Optimizations
  12. 35:12Compiler Versions
  13. 37:35ID and Reger Workaround
  14. 39:21Inline vs NonInline
  15. 41:07Serial Port Code
  16. 42:16Template Versions
  17. 44:05Takeaways
  18. 46:14Questions
  19. 47:43Memory Barriers
  20. 49:35Deprecation
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.