]> git.ipfire.org Git - thirdparty/gcc.git/blobdiff - libitm/method-ml.cc
PR c++/80560 - warn on undefined memory operations involving non-trivial types
[thirdparty/gcc.git] / libitm / method-ml.cc
index fcae334c385a2a03ea501caac6c1dc102737ba4b..b857bff59fe593d276981b722d95f196a34bc84c 100644 (file)
@@ -138,7 +138,11 @@ struct ml_mg : public method_group
     // This store is only executed while holding the serial lock, so relaxed
     // memory order is sufficient here.  Same holds for the memset.
     time.store(0, memory_order_relaxed);
-    memset(orecs, 0, sizeof(atomic<gtm_word>) * L2O_ORECS);
+    // The memset below isn't strictly kosher because it bypasses
+    // the non-trivial assignment operator defined by std::atomic.  Using
+    // a local void* is enough to prevent GCC from warning for this.
+    void *p = orecs;
+    memset(p, 0, sizeof(atomic<gtm_word>) * L2O_ORECS);
   }
 };