Skip to content

Conversation

@nobu
Copy link
Member

@nobu nobu commented Jan 29, 2025

Expressions joined with && are better asserted separately, so that it is clear from the failure message which expression is false.

Also, unsigned long may not be enough for ptrdiff_t, e.g., Windows.
Saying that ptrdiff_t can be larger than SIZE_MAX means that PTRDIFF_MAX is larger than SIZE_MAX and ptrdiff_t is sufficient to represent SIZE_MAX, otherwise if PTRDIFF_MAX is smaller than SIZE_MAX, diff will always be smaller than SIZE_MAX as well.
diff could be equal to SIZE_MAX only if PTRDIFF_MAX is equal to SIZE_MAX and these assertions would pass, but I don't think there is any platform where that is the case.

Expressions joined with `&&` are better asserted separately, so that
it is clear from the failure message which expression is false.

Also, `unsigned long` may not be enough for `ptrdiff_t`, e.g., Windows.
Saying that `ptrdiff_t` can be larger than `SIZE_MAX` means that
`PTRDIFF_MAX` is larger than `SIZE_MAX` and `ptrdiff_t` is sufficient
to represent `SIZE_MAX`, otherwise if `PTRDIFF_MAX` is smaller than
`SIZE_MAX`, `diff` will always be smaller than `SIZE_MAX` as well.
`diff` could be equal to `SIZE_MAX` only if `PTRDIFF_MAX` is equal to
`SIZE_MAX` and these assertions would pass, but I don't think there is
any platform where that is the case.
@kddnewton kddnewton merged commit afa9c27 into ruby:main Feb 13, 2025
59 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