Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@JMazurkiewicz
Copy link
Contributor

  • Rename _(Add|Multiply)_with_overflow_check to _Add_overflow and _Mul_overflow for simplicity,
    • This matches naming of Clang's builtins (__builtin_add_overflow and __builtin_mul_overflow),
  • Move both functions to <xutility>,
    • Both functions are going to be used in <mdspan> implementation,
  • Add separate tests, which detected two bugs:
    • When both arguments to _Mul_overflow are equal to numeric_limits<uint16_t>::max(), then signed integer overflow occurs,
    • There were missing static_casts in _Mul_overflow's LLVM-based branch,
    • Both bugs are fixed in this PR.

@JMazurkiewicz JMazurkiewicz requested a review from a team as a code owner April 29, 2023 19:23
@StephanTLavavej StephanTLavavej added the bug Something isn't working label May 1, 2023
@StephanTLavavej

This comment was marked as resolved.

@barcharcraz barcharcraz removed their assignment May 4, 2023
Copy link
Contributor

@strega-nil-ms strega-nil-ms left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks reasonable to me. Thanks for fixing the unsigned short UB!

@jovibor
Copy link
Contributor

jovibor commented May 16, 2023

@StephanTLavavej StephanTLavavej self-assigned this May 17, 2023
@StephanTLavavej
Copy link
Member

I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed.

@CaseyCarter CaseyCarter merged commit 1fbf725 into microsoft:main May 18, 2023
@CaseyCarter
Copy link
Contributor

Thanks for fixing bugs in these functions that are supposed to defend against bugs.

@JMazurkiewicz JMazurkiewicz deleted the checked-arithmetics branch May 18, 2023 16:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants