You do not seem to have a clear understanding of what “variability” means. The value is more or less "Hello, compiler, please note that someone else will change this variable, so you cannot assume that if your code does not write, the value will remain constant. In addition, someone can watch this a variable, so when I write this variable, please don’t do the weird thing on the assumption that it doesn’t matter, because for those other guys who watch it it’s important, just write what I want you to write, and when I tell you to do it. "
When is it important to use "volatile?" Here is an example:
volatile int stopflag;
If the code at three points never touches the stopflag and never calls a function with an unknown implementation, then the compiler may be tempted to avoid reading the flag in a loop, because looking at the code itself, it seems that there is no need to read the variable at all ... just set and loop forever.
Another case could be:
extern volatile unsigned char outloc;
Here, without volatile , the compiler may be tempted to just write 0xFF in place instead of writing all the intermediate values.
Please note that using volatile to synchronize threads on modern hardware is not enough. On modern computers, the processor is usually multi-core, and therefore writing and reading is no longer an atomic operation. Although in the past (on single-core processors) in practice it was often possible to use mutable variables to synchronize threads, now this is a lie.
It seems to you really interesting to say that buffer is indeed read and written by others, but in this case the buffer address is publicly available, therefore, whenever a function is called (unless it is built-in or has a known implementation code), the compiler should assume that the contents of the buffer are possible changed or will be read by an unknown code.
I would promise that the thread synchronization primitives are properly declared to make sure this is also true in your case (even if strcpy is inline).