diff --git a/openmp/libomptarget/DeviceRTL/include/State.h b/openmp/libomptarget/DeviceRTL/include/State.h index 3365b054b4720..2f9cbd4c9ca6e 100644 --- a/openmp/libomptarget/DeviceRTL/include/State.h +++ b/openmp/libomptarget/DeviceRTL/include/State.h @@ -124,20 +124,21 @@ template struct PtrValue { template struct ValueRAII { ValueRAII(VTy &V, Ty NewValue, Ty OldValue, bool Active, IdentTy *Ident) - : Ptr(Active ? V.lookup(/* IsReadonly */ false, Ident) : Val), + : Ptr(Active ? &V.lookup(/* IsReadonly */ false, Ident) : nullptr), Val(OldValue), Active(Active) { if (!Active) return; - ASSERT(Ptr == OldValue && "ValueRAII initialization with wrong old value!"); - Ptr = NewValue; + ASSERT(*Ptr == OldValue && + "ValueRAII initialization with wrong old value!"); + *Ptr = NewValue; } ~ValueRAII() { if (Active) - Ptr = Val; + *Ptr = Val; } private: - Ty &Ptr; + Ty *Ptr; Ty Val; bool Active; };