Skip to content

Avoid undefined behavior in asarray with very large intergers #383

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

Conversation

cbourjau
Copy link
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
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