https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105519
--- Comment #3 from Andrew Pinski <pinskia at gcc dot gnu.org> --- template <class Tp> __attribute__((noipa)) void DoNotOptimize(Tp& value) {} Is a better way. Yes it will still have a function call but really this is just all to do microbenchmarking so it is not even a high thing to deal with.