> Did you try the access attribute?
> https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html
Oh, I didn't know about this one. But it doesn't seem to change the
generated code... Maybe it is only used for diagnostic error messages?
Or for older versions of GCC using the pure attribute seems to work as
you want too.
Unfortunately, the reader function in the example is not pure.
Annotating it with __attribute__((pure)) causes GCC to warn about the
"void" return type and the function call is completely removed from the
generated code.
But it's still a great idea! I'm sure that there we have a couple of
other functions that we could annotate this way.