https://gcc.gnu.org/bugzilla/show_bug.cgi?id=80114
--- Comment #5 from Jani Nikula <jani.nikula at intel dot com> --- (In reply to Martin Liška from comment #4) > How common is such situation and why do you use volatile keyword in > combination with a constant index? I didn't write the sample, I think the goal of 'volatile' was to ensure the compiler doesn't optimize it all away. The sample comes from a trick in kernel code to pick a constant based on a limited range variable. For example, you have one hardware register per port, the register offsets aren't uniformly distributed, and you want to have macros of the form FOO(port) to give you the right register offset based on the port. So you could have: #define _PICK(__index, ...) (((const u32 []){ __VA_ARGS__ })[__index]) #define FOO(x) _PICK(x, 1, 2, 3) instead of things like: #define _PICK(__index, a, b, c) ((__index) == 0 ? (a) : (__index) == 1 ? (b) : (c)) If you have clever ideas how to neatly handle this otherwise, expecially when the number of ports increases, I'm all ears!