Skip to content

Conversation

@chris-eibl
Copy link
Member

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

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)){returnPyStackRef_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-SpinnerFidget-Spinner merged commit 8272660 into python:mainJun 20, 2025
47 checks passed
@chris-eiblchris-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 freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@chris-eibl@Fidget-Spinner