Skip to content

[test/Prototypes] Fix DoubleWidth think-os #70289

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2023

Conversation

xwu
Copy link
Collaborator

@xwu xwu commented Dec 7, 2023

Aligns the implementation with fixes already committed in the apple/swift-numerics repository:

Since it turns out there's more than one calling site for _divide that doesn't ensure the invariant asserted on line 598, we should actually deal with this in one place by replacing the assertion with a guard that handles the special case.

Additionally, fix another think-o related to full-width multiplication where a carry isn't accounted for, causing unintended overflow with certain inputs.

This type now gives correct output verified for addition/subtraction/multiplication/nonzero-division-with-overflow for every pair of 16-bit unsigned integers using DoubleWidth<DoubleWidth<UInt4>> (with a custom UInt4 implementation).

Resolves apple/swift-numerics#272.

Aligns the implementation with fixes already committed in the apple/swift-numerics repository
@xwu
Copy link
Collaborator Author

xwu commented Dec 7, 2023

@swift-ci smoke test

@xwu xwu requested a review from stephentyrone December 7, 2023 12:37
@xwu xwu merged commit 090a047 into swiftlang:main Dec 7, 2023
@xwu xwu deleted the fire-burn-and-cauldron-bubble branch December 7, 2023 14:48
Catfish-Man pushed a commit to Catfish-Man/swift that referenced this pull request Jan 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Crash in DoubleWidth
2 participants