KEMBAR78
gh-135379: fix MSVC warning: conversion from 'stwodigits' to 'digit' by chris-eibl · Pull Request #135714 · python/cpython · GitHub
Skip to content

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
Pranjal095 pushed a commit to Pranjal095/cpython that referenced this pull request Jul 12, 2025
…igit' (pythonGH-135714)

fix warning C4244: 'initializing': conversion from

'stwodigits' to 'digit', possible loss of data
taegyunkim pushed a commit to taegyunkim/cpython that referenced this pull request Aug 4, 2025
…igit' (pythonGH-135714)

fix warning C4244: 'initializing': conversion from

'stwodigits' to 'digit', possible loss of data
Agent-Hellboy pushed a commit to Agent-Hellboy/cpython that referenced this pull request Aug 19, 2025
…igit' (pythonGH-135714)

fix warning C4244: 'initializing': conversion from

'stwodigits' to 'digit', possible loss of data
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