“Escape” and “Clobber” equivalent in MSVC
问题 In Chandler Carruth's CppCon 2015 talk he introduces two magical functions for defeating the optimizer without any extra performance penalties. For reference, here are the functions (using GNU-style inline assembly): void escape(void* p) { asm volatile("" : : "g"(p) : "memory"); } void clobber() { asm volatile("" : : : "memory"); } It works on any compiler which supports GNU-style inline assembly (GCC, Clang, Intel's compiler, possibly others). However, he mentions it doesn't work in MSVC.