فهرست منبع

Shifting a number into the sign bit of a signed integer is UB

Shift as a unsigned number instead.
Anonymous Maarten 4 روز پیش
والد
کامیت
df72e3f59d
1فایلهای تغییر یافته به همراه1 افزوده شده و 1 حذف شده
  1. 1 1
      test/testatomic.c

+ 1 - 1
test/testatomic.c

@@ -101,7 +101,7 @@ static void RunBasicTest(void)
 #define VALBITS  (sizeof(atomicValue) * 8)
 #define VALBITS  (sizeof(atomicValue) * 8)
 
 
 #define atomicValue int
 #define atomicValue int
-#define CountTo     ((atomicValue)((unsigned int)(1 << (VALBITS - 1)) - 1))
+#define CountTo     ((atomicValue)((1u << (VALBITS - 1)) - 1))
 #define NInter      (CountTo / CountInc / NThreads)
 #define NInter      (CountTo / CountInc / NThreads)
 #define Expect      (CountTo - NInter * CountInc * NThreads)
 #define Expect      (CountTo - NInter * CountInc * NThreads)