diff --git a/sycl/include/CL/sycl/property_list.hpp b/sycl/include/CL/sycl/property_list.hpp index 439b2b1acc931..fbc3ef7bf5402 100644 --- a/sycl/include/CL/sycl/property_list.hpp +++ b/sycl/include/CL/sycl/property_list.hpp @@ -84,14 +84,16 @@ template class PropertyHolder { ~PropertyHolder() { if (m_Initialized) { - (*(T *)m_Mem).~T(); + T *MemPtr = reinterpret_cast(m_Mem); + MemPtr->~T(); } } PropertyHolder &operator=(const PropertyHolder &Other) { if (this != &Other) { if (m_Initialized) { - (*(T *)m_Mem).~T(); + T *MemPtr = reinterpret_cast(m_Mem); + MemPtr->~T(); m_Initialized = false; } @@ -110,7 +112,8 @@ template class PropertyHolder { const T &getProp() const { assert(true == m_Initialized && "Property was not set!"); - return *(const T *)m_Mem; + const T *MemPtr = reinterpret_cast(m_Mem); + return *MemPtr; } bool isInitialized() const { return m_Initialized; }