GCC16.1 optimizes away the write when we use benchmark::DoNotOptimize.
Minimal reproducible example
void f() {
int *a = new int[1 << 16];
for (int i = 0; i < 1 << 16; i++) {
benchmark::DoNotOptimize(a[i] = 10); // this is optimized away by the compiler
}
delete[] a;
}
Compiler explorer(CE) link: https://godbolt.org/z/j538536ss. The CE link contains a possible fix for the issue.
GCC16.1 optimizes away the write when we use
benchmark::DoNotOptimize.Minimal reproducible example
Compiler explorer(CE) link: https://godbolt.org/z/j538536ss. The CE link contains a possible fix for the issue.