[compiler-rt] [scudo] Avoid deprecated-volatile warning in HybridMutex::delayLoop (PR #67135)

via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 22 06:22:59 PDT 2023


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-compiler-rt-sanitizer

<details>
<summary>Changes</summary>

That can prevent compilation with -Werror and -std=c++20:
mutex.h:63:7: error: increment of object of volatile-qualified type 'volatile u32' (aka 'volatile unsigned int') is deprecated [-Werror,-Wdeprecated-volatile]


---
Full diff: https://github.com/llvm/llvm-project/pull/67135.diff


1 Files Affected:

- (modified) compiler-rt/lib/scudo/standalone/mutex.h (+6-2) 


``````````diff
diff --git a/compiler-rt/lib/scudo/standalone/mutex.h b/compiler-rt/lib/scudo/standalone/mutex.h
index 38108397b1654bb..1563cdb3fb109cb 100644
--- a/compiler-rt/lib/scudo/standalone/mutex.h
+++ b/compiler-rt/lib/scudo/standalone/mutex.h
@@ -58,9 +58,13 @@ class CAPABILITY("mutex") HybridMutex {
     // are the fastest operations) so that we are unlikely to wait too long for
     // fast operations.
     constexpr u32 SpinTimes = 16;
-    volatile u32 V = 0;
+
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wunused-but-set-variable"
+    volatile u32 V;
     for (u32 I = 0; I < SpinTimes; ++I)
-      ++V;
+      V = 0;
+#pragma GCC diagnostic pop
   }
 
   void assertHeldImpl();

``````````

</details>


https://github.com/llvm/llvm-project/pull/67135


More information about the llvm-commits mailing list