Skip to content

Fail instead of trying to cast Inf to int#1458

Merged
Enchufa2 merged 2 commits intomasterfrom
intinf
Feb 27, 2026
Merged

Fail instead of trying to cast Inf to int#1458
Enchufa2 merged 2 commits intomasterfrom
intinf

Conversation

@Enchufa2
Copy link
Member

Closes #1455.

min(integer(0)) shows a warning and results in a numeric value. We cannot do that (because we keep the same type in storage instead of returning a SEXP), so I think that it's best to just throw an error in such cases.

Checklist

  • Code compiles correctly
  • R CMD check still passes all tests
  • Preferably, new tests were added which fail without the change
  • Document the changes by file in ChangeLog

@Enchufa2 Enchufa2 changed the title Intinf Fail instead of trying to cast Inf to int Feb 27, 2026
@Enchufa2 Enchufa2 marked this pull request as ready for review February 27, 2026 12:51
Copy link
Member

@eddelbuettel eddelbuettel 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 good. Do you think you can toss in a check for REAL returning limits as expected?

Copy link
Member

@eddelbuettel eddelbuettel left a comment

Choose a reason for hiding this comment

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

Sorry about 'da noise'. Looks good.

@Enchufa2
Copy link
Member Author

Thanks, merging this now, will rebase the other one after revdep checks.

@Enchufa2 Enchufa2 merged commit 5fd3b68 into master Feb 27, 2026
26 checks passed
@Enchufa2 Enchufa2 deleted the intinf branch February 27, 2026 13:53
@eddelbuettel
Copy link
Member

eddelbuettel commented Feb 27, 2026

Well these are 'behavior changes' (that are obviously merited) so we need rev.deps (in case we need to talk affected maintainers). "Moar cpus" would be good; back on planet earth we just wait.

@Enchufa2
Copy link
Member Author

Ops, you are right, I should have waited. In my defense, if someone was using min/max on an empty integer vector, this would have been flagged on CRAN by UBSAN checks, so it is extremely unlikely that there are any issues in revdep checks after this change.

@eddelbuettel
Copy link
Member

Agreed. And if there is something we will catch it in the next wave of tests.

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.

Inf outside of representable range of type 'int' in sugar functions

2 participants