diff --git a/src/coreclr/gc/env/volatile.h b/src/coreclr/gc/env/volatile.h index e1c014543139a0..21a83f9b682054 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 efcb25f8acd8a5..5d42fc0ffbd95c 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 //