Skip to content
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

Fix incorrect comparison in sparse, convert all operator bool to explicit #3817

Merged
merged 3 commits into from
Jan 27, 2024

Conversation

ishitatsuyuki
Copy link
Contributor

@mastercoms found an incorrectly coded comparison logic in sparse. The first commit fixes it.

The reason type checker let this through was because some surprising implicit conversion done by operator bool. Mark all operator bool as explicit to prevent any similar bug from happening in the future.

m_mappings[page] was getting implicitly converted to bool.
When assigning to a BOOL (which is an uint in disguise) and using explicit
bool conversion operators (introduced in a latter commit) an explicit cast
is required.
Non-explicit conversion operators in general can participate in very
surprising conversion chains. Explicit bool operator is a good place to
start with, because even with explicit they do get automatic contextual
conversion in a lot of places, e.g., if conditions.
@doitsujin doitsujin merged commit e2a46a3 into doitsujin:master Jan 27, 2024
3 checks passed
@ishitatsuyuki ishitatsuyuki deleted the explicit-bool branch January 27, 2024 10:45
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