"volatile" is not a synchronization primitive and doesn't forbid reordering amongst access to different memory locations.
All it does is forbid reordering or removing accesses to a particular memory location.
Historically, many compilers implemented it as a hard memory barrier, but that isn't how the standard defines it.