Skip to content

Resolve gh-2882#2930

Open
ndgrigorian wants to merge 6 commits into
masterfrom
resolve-gh-2882
Open

Resolve gh-2882#2930
ndgrigorian wants to merge 6 commits into
masterfrom
resolve-gh-2882

Conversation

@ndgrigorian
Copy link
Copy Markdown
Collaborator

This PR adds a fix for gh-2882

When floats were previously converted by convert_impl to unsigned integral types, they would pass through an equally sized, signed integral type

If the float was in bounds for the unsigned integral type but out of bounds for the signed type, however, undefined behavior could be encountered.

This PR proposes a solution of casting to a sufficiently large intermediate type first, before casting into the unsigned integral type.

  • Have you provided a meaningful PR description?
  • Have you added a test, reproducer or referred to an issue with a reproducer?
  • Have you tested your changes locally for CPU and GPU devices?
  • Have you made sure that new changes do not introduce compiler warnings?
  • Have you checked performance impact of proposed changes?
  • Have you added documentation for your changes, if necessary?
  • Have you added your changes to the changelog?

float to unsigned integer casts could encounter undefined behavior when the float passes through a signed integral type, where the intermediate signed integral type could overflow
ndgrigorian added a commit that referenced this pull request May 22, 2026
@ndgrigorian ndgrigorian marked this pull request as ready for review May 22, 2026 08:55
@antonwolfy antonwolfy added this to the 0.21.0 release milestone May 22, 2026
@github-actions
Copy link
Copy Markdown
Contributor

View rendered docs @ https://intelpython.github.io/dpnp/pull/2930/index.html

@coveralls
Copy link
Copy Markdown
Collaborator

Coverage Status

coverage: 78.237% (-0.002%) from 78.239% — resolve-gh-2882 into master

@github-actions
Copy link
Copy Markdown
Contributor

Array API standard conformance tests for dpnp=0.21.0dev0=py313h509198e_48 ran successfully.
Passed: 1356
Failed: 4
Skipped: 16

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.

3 participants