File tree Expand file tree Collapse file tree 1 file changed +4
-2
lines changed
Expand file tree Collapse file tree 1 file changed +4
-2
lines changed Original file line number Diff line number Diff line change @@ -181,7 +181,8 @@ namespace xsimd
181181 static_assert (shift < bits, " Shift must be less than the number of bits in T" );
182182 XSIMD_IF_CONSTEXPR (sizeof (T) == 1 )
183183 {
184- constexpr uint8_t mask8 = static_cast <uint8_t >(~0u << shift);
184+ // TODO(C++17): without `if constexpr` we must ensure the compile-time shift does not overflow
185+ constexpr uint8_t mask8 = static_cast <uint8_t >(sizeof (T) == 1 ? (~0u << shift) : 0 );
185186 __m256i const mask = _mm256_set1_epi8 (mask8);
186187 return _mm256_and_si256 (_mm256_slli_epi16 (self, shift), mask);
187188 }
@@ -314,7 +315,8 @@ namespace xsimd
314315 {
315316 XSIMD_IF_CONSTEXPR (sizeof (T) == 1 )
316317 {
317- constexpr uint8_t mask8 = static_cast <uint8_t >((1u << shift) - 1u );
318+ // TODO(C++17): without `if constexpr` we must ensure the compile-time shift does not overflow
319+ constexpr uint8_t mask8 = static_cast <uint8_t >(sizeof (T) == 1 ? ((1u << shift) - 1u ) : 0 );
318320 __m256i const mask = _mm256_set1_epi8 (mask8);
319321 return _mm256_and_si256 (_mm256_srli_epi16 (self, shift), mask);
320322 }
You can’t perform that action at this time.
0 commit comments