Skip to content

Commit 9dc1b2c

Browse files
committed
Proper MSVC warning fix and note
1 parent 0a40449 commit 9dc1b2c

1 file changed

Lines changed: 3 additions & 8 deletions

File tree

concurrentqueue.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -476,15 +476,10 @@ namespace details
476476
template<typename T>
477477
static inline bool circular_less_than(T a, T b)
478478
{
479-
#ifdef _MSC_VER
480-
#pragma warning(push)
481-
#pragma warning(disable: 4554)
482-
#endif
483479
static_assert(std::is_integral<T>::value && !std::numeric_limits<T>::is_signed, "circular_less_than is intended to be used only with unsigned integer types");
484-
return static_cast<T>(a - b) > static_cast<T>(static_cast<T>(1) << static_cast<T>(sizeof(T) * CHAR_BIT - 1));
485-
#ifdef _MSC_VER
486-
#pragma warning(pop)
487-
#endif
480+
return static_cast<T>(a - b) > static_cast<T>(static_cast<T>(1) << (static_cast<T>(sizeof(T) * CHAR_BIT - 1)));
481+
// Note: extra parens around rhs of operator<< is MSVC bug: https://developercommunity2.visualstudio.com/t/C4554-triggers-when-both-lhs-and-rhs-is/10034931
482+
// silencing the bug requires #pragma warning(disable: 4554) around the calling code and has no effect when done here.
488483
}
489484

490485
template<typename U>

0 commit comments

Comments
 (0)