From b6df00aebf63bd64bfa3923dca54717500fc4f8f Mon Sep 17 00:00:00 2001 From: Fabio D'Urso Date: Fri, 22 Sep 2023 15:10:40 +0200 Subject: [PATCH 1/2] [scudo] Avoid deprecated-volatile warning in HybridMutex::delayLoop 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] --- compiler-rt/lib/scudo/standalone/mutex.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/compiler-rt/lib/scudo/standalone/mutex.h b/compiler-rt/lib/scudo/standalone/mutex.h index 38108397b1654..1563cdb3fb109 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(); From 619693914b1f07a248aa8c128ef00a4f59cdd9af Mon Sep 17 00:00:00 2001 From: Fabio D'Urso Date: Fri, 22 Sep 2023 18:53:01 +0200 Subject: [PATCH 2/2] Incorporate feedback --- compiler-rt/lib/scudo/standalone/mutex.h | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/compiler-rt/lib/scudo/standalone/mutex.h b/compiler-rt/lib/scudo/standalone/mutex.h index 1563cdb3fb109..4caa945219b52 100644 --- a/compiler-rt/lib/scudo/standalone/mutex.h +++ b/compiler-rt/lib/scudo/standalone/mutex.h @@ -58,13 +58,11 @@ class CAPABILITY("mutex") HybridMutex { // are the fastest operations) so that we are unlikely to wait too long for // fast operations. constexpr u32 SpinTimes = 16; - -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wunused-but-set-variable" - volatile u32 V; - for (u32 I = 0; I < SpinTimes; ++I) - V = 0; -#pragma GCC diagnostic pop + volatile u32 V = 0; + for (u32 I = 0; I < SpinTimes; ++I) { + u32 Tmp = V + 1; + V = Tmp; + } } void assertHeldImpl();