Index: compiler-rt/lib/ubsan/ubsan_value.cpp =================================================================== --- compiler-rt/lib/ubsan/ubsan_value.cpp +++ compiler-rt/lib/ubsan/ubsan_value.cpp @@ -74,7 +74,7 @@ // to SIntMax. const unsigned ExtraBits = sizeof(SIntMax) * 8 - getType().getIntegerBitWidth(); - return SIntMax(Val) << ExtraBits >> ExtraBits; + return SIntMax(UIntMax(Val) << ExtraBits) >> ExtraBits; } if (getType().getIntegerBitWidth() == 64) return *reinterpret_cast(Val);