diff --git a/src/coreclr/gc/env/volatile.h b/src/coreclr/gc/env/volatile.h index c40e5c2d60964e..bd2d8df58d7c2b 100644 --- a/src/coreclr/gc/env/volatile.h +++ b/src/coreclr/gc/env/volatile.h @@ -469,6 +469,16 @@ class VolatilePtr : public Volatile

{ } + // + // Bring the base class operator= into scope. + // + using Volatile

::operator=; + + // + // Copy assignment operator. + // + inline VolatilePtr& operator=(const VolatilePtr& other) {this->Store(other.Load()); return *this;} + // // Cast to the pointer type // diff --git a/src/coreclr/inc/volatile.h b/src/coreclr/inc/volatile.h index 177c4932166c69..7bd16a2254eec9 100644 --- a/src/coreclr/inc/volatile.h +++ b/src/coreclr/inc/volatile.h @@ -517,6 +517,19 @@ class VolatilePtr : public Volatile

STATIC_CONTRACT_SUPPORTS_DAC; } + // + // Bring the base class operator= into scope. Without this, the compiler-generated + // copy assignment operator hides Volatile

::operator= and performs a plain store, + // bypassing the memory barriers provided by VolatileStore. + // + using Volatile

::operator=; + + // + // Copy assignment operator. The using declaration above does not suppress the + // compiler-generated copy assignment, so we must define it explicitly. + // + inline VolatilePtr& operator=(const VolatilePtr& other) {this->Store(other.Load()); return *this;} + // // Cast to the pointer type //