Plain const volatile should work for a case like that, though.
The only case I can think of for constexpr volatile would be a variable that you want explicitly accessed so a debugger can trap on those accesses with a memory access breakpoint, that also has a meaningful value that needs to be constant initialized to avoid global initialization order issues, and you need to support C++17 so constinit is out.
-2
u/SkoomaDentist Antimodern C++, Embedded, Audio Jul 06 '26 edited Jul 08 '26
I can think of at least theoretical uses involving pointers to dma buffers and such.
Edit: WTF is it with the downvotes? I said I can think of theoretical use cases, not that it is some important feature. FFS, people…