Skip to content
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

fix: resolve UB in _add, __sub, _mul for u8, u16, u32 #6654

Draft
wants to merge 18 commits into
base: master
Choose a base branch
from
Draft

Conversation

K1-R1
Copy link
Member

@K1-R1 K1-R1 commented Oct 17, 2024

Description

handle u32 and u16 subtract underflow manually.
Mirror u8 impl's use of u64 conversion for u16 and u32.
Add additional u8 test.
Closes #6653.
Closes #6666.

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@K1-R1 K1-R1 added bug Something isn't working lib: core Core library labels Oct 17, 2024
@K1-R1 K1-R1 self-assigned this Oct 17, 2024
@K1-R1 K1-R1 marked this pull request as ready for review October 17, 2024 11:34
@K1-R1 K1-R1 requested review from a team as code owners October 17, 2024 11:34
SwayStar123
SwayStar123 previously approved these changes Oct 17, 2024
sway-lib-core/src/ops.sw Show resolved Hide resolved
sway-lib-core/src/ops.sw Show resolved Hide resolved
sway-lib-core/src/ops.sw Outdated Show resolved Hide resolved
@K1-R1 K1-R1 changed the title fix: handle u32 and u16 subtract underflow manually fix: resolve UB in _add, __sub, _mul for u8, u16, u32 Oct 23, 2024
@K1-R1 K1-R1 requested review from a team October 23, 2024 08:00
@K1-R1 K1-R1 marked this pull request as draft October 29, 2024 10:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working lib: core Core library
Projects
None yet
4 participants