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

Add checked numeric cast #2315

Merged
merged 2 commits into from
Feb 22, 2023
Merged

Add checked numeric cast #2315

merged 2 commits into from
Feb 22, 2023

Conversation

AntoinePrv
Copy link
Member

This PR adds a checked numeric cast to make checked conversion whenever we currently have a warning or a silencing static_cast without checks.

@AntoinePrv AntoinePrv changed the title A check numeric cast Add checked numeric cast Feb 21, 2023
@AntoinePrv AntoinePrv self-assigned this Feb 21, 2023
}
else
{
using float_type = std::common_type_t<From, To>;
Copy link
Member

Choose a reason for hiding this comment

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

Do we do a lot of casting between float types? Seems to me we should rather get rid of it if possible.

The integer ones are obviously necessary since libsolv uses 32 bit integers in quite some places.

Copy link
Member Author

Choose a reason for hiding this comment

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

Do we do a lot of casting between float types? Seems to me we should rather get rid of it if possible.

I think I've seen a couple casting from integer to float but perhaps they need not be exact.

The integer ones are obviously necessary since libsolv uses 32 bit integers in quite some places.

Yes, even between signed and unsigned.

@AntoinePrv AntoinePrv merged commit 82d0628 into mamba-org:main Feb 22, 2023
@AntoinePrv AntoinePrv deleted the cast branch March 2, 2023 13:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants