]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/Math64.c
MdePkg/BaseLib: do not rely on undefined behavior in arithmetic shift
[mirror_edk2.git] / MdePkg / Library / BaseLib / Math64.c
index 83d76847213e3b181f3aa59403cb952e38377818..9624cf90029f801d10d0a44381ec118237243cd1 100644 (file)
@@ -86,7 +86,7 @@ InternalMathARShiftU64 (
   //\r
   // Test if this compiler supports arithmetic shift\r
   //\r
-  TestValue = (((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1));\r
+  TestValue = (INTN)((INT64)(1ULL << 63) >> 63);\r
   if (TestValue == -1) {\r
     //\r
     // Arithmetic shift is supported\r