Chandler Carruth introduced two functions in his CppCon2015 talk that can be used to do some fine-grained inhibition of the optimizer. They are useful to write micro-benchma
I have used the following in place of escape.
#ifdef _MSC_VER
#pragma optimize("", off)
template
inline void escape(T* p) {
*reinterpret_cast(p) =
*reinterpret_cast(p); // thanks, @milleniumbug
}
#pragma optimize("", on)
#endif
It's not perfect but it's close enough, I think.
Sadly, I don't have a way to emulate clobber.