[gperftools] Fix volatile usage for C++20

TEST=no behavior change

Change-Id: Id66a4107cf484b9dbba0f514fdfd693b17135c4e
Reviewed-on: https://fuchsia-review.googlesource.com/c/third_party/github.com/gperftools/gperftools/+/635743
Reviewed-by: Roland McGrath <mcgrathr@google.com>
diff --git a/src/sampler.h b/src/sampler.h
index 2d6c504..9d81c49 100644
--- a/src/sampler.h
+++ b/src/sampler.h
@@ -207,7 +207,7 @@
     // sub <reg>, <mem> instruction for subtraction above.
     volatile ssize_t *ptr =
         const_cast<volatile ssize_t *>(&bytes_until_sample_);
-    *ptr += k;
+    *ptr = *ptr + k;
     return false;
   }
   return true;
diff --git a/src/tests/profiler_unittest.cc b/src/tests/profiler_unittest.cc
index dfc653f..d98f8b2 100644
--- a/src/tests/profiler_unittest.cc
+++ b/src/tests/profiler_unittest.cc
@@ -60,7 +60,7 @@
   MutexLock ml(&mutex);
   for (m = 0; m < 1000000; ++m) {          // run millions of times
     for (i = 0; i < g_iters; ++i ) {
-      result ^= i;
+      result = result ^ i;
     }
     snprintf(b, sizeof(b), "other: %d", result);  // get some libc action
   }
@@ -73,7 +73,7 @@
   MutexLock ml(&mutex);
   for (m = 0; m < 1000000; ++m) {          // run millions of times
     for (i = 0; i < g_iters; ++i ) {
-      result ^= i;
+      result = result ^ i;
     }
     snprintf(b, sizeof(b), "same: %d", result);  // get some libc action
   }