From cb5b06d7d499cbee30d5fa4ee9bbbb9fc532c2f9 Mon Sep 17 00:00:00 2001 From: Nicholas Hastings Date: Mon, 27 Apr 2026 01:43:11 +0000 Subject: [PATCH] Compatibility fixes for Clang 22 --- public/bitvec.h | 6 +++--- public/sentence.cpp | 2 +- public/sentence.h | 2 +- public/studio.h | 4 ++-- public/tier0/platform.h | 2 +- public/tier0/threadtools.h | 2 +- public/tier1/utlblockmemory.h | 5 +++-- 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/public/bitvec.h b/public/bitvec.h index fe2414aa..c6471cdb 100644 --- a/public/bitvec.h +++ b/public/bitvec.h @@ -448,7 +448,7 @@ typedef CBitVec<32> CDWordBitVec; template inline CVarBitVecBase::CVarBitVecBase() { - Plat_FastMemset( this, 0, sizeof( *this ) ); + Plat_FastMemset( (void *)this, 0, sizeof( *this ) ); } //----------------------------------------------------------------------------- @@ -479,7 +479,7 @@ inline CVarBitVecBase::CVarBitVecBase( const CVarBitVecBase::Detach( uint32 **ppBits, int *pNumBits free( m_pInt ); } - memset( this, 0, sizeof( *this ) ); + memset( (void *)this, 0, sizeof( *this ) ); return true; } diff --git a/public/sentence.cpp b/public/sentence.cpp index e9f17fb7..f6c21ef0 100644 --- a/public/sentence.cpp +++ b/public/sentence.cpp @@ -240,7 +240,7 @@ CBasePhonemeTag::CBasePhonemeTag() CBasePhonemeTag::CBasePhonemeTag( const CBasePhonemeTag& from ) { - memcpy( this, &from, sizeof(*this) ); + memcpy( (void *)this, &from, sizeof(*this) ); } diff --git a/public/sentence.h b/public/sentence.h index ee547948..478d1152 100644 --- a/public/sentence.h +++ b/public/sentence.h @@ -48,7 +48,7 @@ public: CBasePhonemeTag(); CBasePhonemeTag( const CBasePhonemeTag& from ); - CBasePhonemeTag &operator=( const CBasePhonemeTag &from ) { memcpy( this, &from, sizeof(*this) ); return *this; } + CBasePhonemeTag &operator=( const CBasePhonemeTag &from ) { memcpy( (void *)this, &from, sizeof(*this) ); return *this; } float GetStartTime() const { return m_flStartTime; } void SetStartTime( float startTime ) { m_flStartTime = startTime; } diff --git a/public/studio.h b/public/studio.h index e642fa54..c4cb1b28 100644 --- a/public/studio.h +++ b/public/studio.h @@ -3170,7 +3170,7 @@ inline int Studio_LoadVertexes( const vertexFileHeader_t *pTempVvdHdr, vertexFil // copy vertexes memcpy( - (mstudiovertex_t *)((byte *)pNewVvdHdr+pNewVvdHdr->vertexDataStart) + target, + (void *)((mstudiovertex_t *)((byte *)pNewVvdHdr+pNewVvdHdr->vertexDataStart) + target), (mstudiovertex_t *)((byte *)pTempVvdHdr+pTempVvdHdr->vertexDataStart) + pFixupTable[i].sourceVertexID, pFixupTable[i].numVertexes*sizeof(mstudiovertex_t) ); @@ -3178,7 +3178,7 @@ inline int Studio_LoadVertexes( const vertexFileHeader_t *pTempVvdHdr, vertexFil { // copy tangents memcpy( - (Vector4D *)((byte *)pNewVvdHdr+pNewVvdHdr->tangentDataStart) + target, + (void *)((Vector4D *)((byte *)pNewVvdHdr+pNewVvdHdr->tangentDataStart) + target), (Vector4D *)((byte *)pTempVvdHdr+pTempVvdHdr->tangentDataStart) + pFixupTable[i].sourceVertexID, pFixupTable[i].numVertexes*sizeof(Vector4D) ); } diff --git a/public/tier0/platform.h b/public/tier0/platform.h index b9163847..eff80da8 100644 --- a/public/tier0/platform.h +++ b/public/tier0/platform.h @@ -1157,7 +1157,7 @@ inline uint64 Plat_Rdtsc() public: \ _classname &operator=( const _classname &src ) \ { \ - memcpy( this, &src, sizeof(_classname) ); \ + memcpy( (void *)this, &src, sizeof(_classname) ); \ return *this; \ } diff --git a/public/tier0/threadtools.h b/public/tier0/threadtools.h index d4eecb5f..cf1c6366 100644 --- a/public/tier0/threadtools.h +++ b/public/tier0/threadtools.h @@ -1068,7 +1068,7 @@ private: class ALIGN8 PLATFORM_CLASS CThreadSpinRWLock { public: - CThreadSpinRWLock() { COMPILE_TIME_ASSERT( sizeof( LockInfo_t ) == sizeof( int64 ) ); Assert( (intp)this % 8 == 0 ); memset( this, 0, sizeof( *this ) ); } + CThreadSpinRWLock() { COMPILE_TIME_ASSERT( sizeof( LockInfo_t ) == sizeof( int64 ) ); Assert( (intp)this % 8 == 0 ); memset( (void *)this, 0, sizeof( *this ) ); } bool TryLockForWrite(); bool TryLockForRead(); diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h index 260d0fe7..9968d60d 100644 --- a/public/tier1/utlblockmemory.h +++ b/public/tier1/utlblockmemory.h @@ -139,8 +139,9 @@ void CUtlBlockMemory::Swap( CUtlBlockMemory< T, I > &mem ) { V_swap( m_pMemory, mem.m_pMemory ); V_swap( m_nBlocks, mem.m_nBlocks ); - V_swap( m_nIndexMask, mem.m_nIndexMask ); - V_swap( m_nIndexShift, mem.m_nIndexShift ); + // Bit-fields cannot bind to non-const references; swap manually. + int nIndexMask = m_nIndexMask; m_nIndexMask = mem.m_nIndexMask; mem.m_nIndexMask = nIndexMask; + int nIndexShift = m_nIndexShift; m_nIndexShift = mem.m_nIndexShift; mem.m_nIndexShift = nIndexShift; }