|
| 1 | +From f3db078d94224f4bebd9c7a8615a277e55b92efe Mon Sep 17 00:00:00 2001 |
| 2 | + |
| 3 | +Date: Thu, 6 Mar 2025 08:14:39 +0000 |
| 4 | +Subject: [PATCH] Fix 'non-const reference cannot bind to bit-field' error with |
| 5 | + newer clang versions |
| 6 | + |
| 7 | +This specifically shows up when trying to use zig 0.14.0 (llvm 19.1.7) to cross-compile to Linux. |
| 8 | + |
| 9 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/sourcemod/public/CDetour/detours.cpp:1: |
| 10 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/sourcemod/public/CDetour/detours.h:36: |
| 11 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/sourcemod/public/smsdk_ext.h:100: |
| 12 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/mmsource/core/ISmmPlugin.h:39: |
| 13 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/mmsource/core/ISmmAPI.h:47: |
| 14 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/eiface.h:16: |
| 15 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/convar.h:21: |
| 16 | + In file included from H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/utlvector.h:25: |
| 17 | + H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/utlblockmemory.h:141:10: error: non-const reference cannot bind to bit-field 'm_nIndexShift' |
| 18 | + 141 | V_swap( m_nIndexShift, mem.m_nIndexShift ); |
| 19 | + | ^~~~~~~~~~~~~ |
| 20 | + H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/tier1/utlblockmemory.h:111:6: note: bit-field is declared here |
| 21 | + 111 | int m_nIndexShift : 5; |
| 22 | + | ^ |
| 23 | + H:\code\srcwr\srcwrtimer/_external/alliedmodders/hl2sdk-css/public/mathlib/mathlib.h:717:29: note: passing argument to parameter 'x' here |
| 24 | + 717 | FORCEINLINE void V_swap( T& x, T& y ) |
| 25 | + | ^ ^ |
| 26 | +--- |
| 27 | + public/tier1/utlblockmemory.h | 8 ++++++-- |
| 28 | + 1 file changed, 6 insertions(+), 2 deletions(-) |
| 29 | + |
| 30 | +diff --git a/public/tier1/utlblockmemory.h b/public/tier1/utlblockmemory.h |
| 31 | +index 8d86c59e..4782e235 100644 |
| 32 | +--- a/public/tier1/utlblockmemory.h |
| 33 | ++++ b/public/tier1/utlblockmemory.h |
| 34 | +@@ -137,8 +137,12 @@ void CUtlBlockMemory<T,I>::Swap( CUtlBlockMemory< T, I > &mem ) |
| 35 | + { |
| 36 | + V_swap( m_pMemory, mem.m_pMemory ); |
| 37 | + V_swap( m_nBlocks, mem.m_nBlocks ); |
| 38 | +- V_swap( m_nIndexMask, mem.m_nIndexMask ); |
| 39 | +- V_swap( m_nIndexShift, mem.m_nIndexShift ); |
| 40 | ++ int tmp = m_nIndexMask; |
| 41 | ++ m_nIndexMask = mem.m_nIndexMask; |
| 42 | ++ mem.m_nIndexMask = tmp; |
| 43 | ++ tmp = m_nIndexShift; |
| 44 | ++ m_nIndexShift = mem.m_nIndexShift; |
| 45 | ++ mem.m_nIndexShift = tmp; |
| 46 | + } |
| 47 | + |
| 48 | + |
| 49 | +-- |
| 50 | +2.47.1.windows.1 |
| 51 | + |
0 commit comments