Skip to content

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

Merged
Fidget-Spinner merged 1 commit into
python:mainfrom
chris-eibl:fix_msvc_warning
Jun 20, 2025
Merged

Fidget-Spinner merged 1 commit into
python:mainfrom
chris-eibl:fix_msvc_warning

Conversation

@chris-eibl

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

Copy link
Copy Markdown
Member

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 Jun 19, 2025
@chris-eibl chris-eibl changed the title gh-135379: fix MSVC warning C4244: 'initializing': conversion from 'stwodigits' to 'digit' Jun 19, 2025
@Fidget-Spinner

Copy link
Copy Markdown
Member

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

@chris-eibl

Copy link
Copy Markdown
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
@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

2 participants