3 ms·
The problem here, I suspect, is that this std::whatever::now() clock is somehow being treated by the compiler as if it requires no sequencing with regard to fun
by kazinator 11y ago
The problem here, I suspect, is that this std::whatever::now() clock is somehow being treated by the compiler as if it requires no sequencing with regard to function calls.
It's probably not that Microsoft's compiler is optimizing through the function pointer, but rather that it thinks that now() doesn't have to be sequenced. And its return value is just assigned to local variables, which have no interaction with the function being called. So if now() doesn't have to be sequenced, the initializations of those variables can be reordered.
This is definitely a bug somewhere between now this now() function is implemented, and how the compiler treats its definition or declaration. A clock-sampling function simply must be properly sequenced with regard to surrounding code.