Skip to content

Avoid undefined behavior in asarray with very large intergers#383

Merged
ev-br merged 1 commit intodata-apis:masterfrom
cbourjau:fix-overflow-asarray-very-large-uints
Jun 4, 2025
Merged

Avoid undefined behavior in asarray with very large intergers#383
ev-br merged 1 commit intodata-apis:masterfrom
cbourjau:fix-overflow-asarray-very-large-uints

Conversation

@cbourjau
Copy link
Copy Markdown
Contributor

@cbourjau cbourjau commented Jun 4, 2025

The min and max values are drawn specifically for their dtypes. This means that they may assume values that overflow the default integer data type. This is explicitly undefined behavior in the standard. This change avoids this UB by passing the dtype parameter to asarray where appropriate.

Copy link
Copy Markdown
Member

@ev-br ev-br left a comment

Choose a reason for hiding this comment

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

Indeed, nice catch!
Thanks @cbourjau

@ev-br ev-br merged commit ddffe11 into data-apis:master Jun 4, 2025
3 checks passed
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.

2 participants