It depends on the system. First, the int would be by value anyway, so it wouldn't matter.
But assume you handed it a pointer instead.
Some are properly marked readonly in declarations, some are not[1]
But this is a common problem with unmarked logging. The compiler will infer attributes all the way through things it has bitcode for.
(IE it can determine it to be readonly, readnone, whatever, as long as it can see calls to either functions marked readonly/readnone, or determine the called functions to be readonly/readnone)
But, usually, if you don't give it the whole program, it can't infer that your logging function does not modify its arguments.
So sadly, it's printf is not readonly, because it can do anything it wants in these callbacks.
(nobody uses the printf registration, though, so it may be time to just add a compiler option required to make it work, and not screw everyone else using printf over)
It may not. It's possible that this may be happening because rustc is failing to mark the reference as both readonly and unaliased, whereas clang might mark the equivalent as both. You'd need to examine the IR from both front ends to really figure out the source of any differences in the generated ASM
If you use printf and cout in the same program then yes you can have dramatic performance problems with cout unless you use `std::ios_base::sync_with_stdio(false);`
It's not the same issue but it's the same area of stupid stuff you have to find out about and roll your eyes.