Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gh-135379: fix MSVC warning: conversion from 'stwodigits' to 'digit' #135714

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
merged 1 commit into from
Jun 20, 2025

Conversation

chris-eibl
Copy link
Member

@chris-eibl chris-eibl commented Jun 19, 2025

Fixes MSVC warning C4244: 'initializing': conversion from 'stwodigits' to 'digit', possible loss of data.

'stwodigits' to 'digit', possible loss of data
@chris-eibl chris-eibl changed the title gh-135379: fix MSVC warning C4244: 'initializing': conversion from 'stwodigits' to 'digit', possible loss of data gh-135379: fix MSVC warning C4244: 'initializing': conversion from 'stwodigits' to 'digit' Jun 19, 2025
@chris-eibl chris-eibl changed the title gh-135379: fix MSVC warning C4244: 'initializing': conversion from 'stwodigits' to 'digit' gh-135379: fix MSVC warning: conversion from 'stwodigits' to 'digit' Jun 19, 2025
@Fidget-Spinner
Copy link
Member

Just checking: what does the rest of longobject do? Sorry I cant check myself as Im on mobile

@chris-eibl
Copy link
Member Author

There are many (digit) casts if something is assigned to a digit, but is a bigger data type.

Here that cast is missing, hence, MSVC fires the warning. Which is of no concern, since a few lines above

    if(!is_medium_int(x)) {
        return PyStackRef_NULL;
    }

ensures that the contents of stwodigits x is small enough to be cast into a digit without loss.

But since here a signed conversion takes place, too, I'd appreciate a second pair of eyes @markshannon ?

@Fidget-Spinner Fidget-Spinner merged commit 8272660 into python:main Jun 20, 2025
47 checks passed
@chris-eibl chris-eibl deleted the fix_msvc_warning branch June 20, 2025 20:51
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.

2 participants