Skip to content

Commit b7f715f

Browse files
author
Max Moiseev
committed
Fixing the iOS test failures
1 parent 71b2c1f commit b7f715f

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

stdlib/public/core/Integers.swift.gyb

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2786,9 +2786,18 @@ public struct ${Self}
27862786

27872787
@_transparent
27882788
public static func %=(_ lhs: inout ${Self}, _ rhs: ${Self}) {
2789+
// No LLVM primitives for checking overflow of division
2790+
// operations, so we check manually.
27892791
if _slowPath(rhs == (0 as ${Self})) {
27902792
_preconditionFailure("Remainder of division by zero")
27912793
}
2794+
% if signed:
2795+
if _slowPath(
2796+
${'lhs == %s.min && rhs == (-1 as %s)' % (Self, Self)}
2797+
) {
2798+
_preconditionFailure("Overflow in remainder of division")
2799+
}
2800+
% end
27922801

27932802
let (newStorage, _) = (
27942803
Builtin.${u}rem_Int${bits}(lhs._value, rhs._value),

test/Prototypes/BigInt.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
// RUN: %target-build-swift -swift-version 4 -o %t/a.out %s
1515
// RUN: %target-run %t/a.out
1616
// REQUIRES: executable_test
17+
// REQUIRES: CPU=x86_64
1718

1819
import StdlibUnittest
1920
import Darwin

0 commit comments

Comments
 (0)