MubinSkt has asked for the wisdom of the Perl Monks concerning the following question:

The INT_PTR as defined by Microsoft in some MSVC files running WinAPIs, is a __int64 in x64 configuration. because of this it is a type mismatch and generates warning C4244 - Severity Code Description Project File Line Suppression State Warning C4244 '=': conversion from 'INT_PTR' to 'I32', possible loss of data PhxProg2 C:\Strawberry\perl\lib\CORE\inline.h 2283 how possibly can we get around this, I believe this will be a problem everywhere the project configuration is x64 and INT_PTR is a __int64.

below is an example of the line having this warning, such multiple warnings exists.  cx->blk_eval.old_cxsubix   = PL_curstackinfo->si_cxsubix;

Replies are listed 'Best First'.
Re: C4244 Warning in inline.h file while using Win64 configuration
by hv (Prior) on Feb 15, 2023 at 18:25 UTC

    It shouldn't be possible to get such a warning on that line, since both old_cxsubix and si_cxsubix have been declared as I32 ever since they were introduced in 2019 (in commit 740449bf22).

    Is it possible it is actually warning about a different line? You probably need to show a more complete example of the output (in code tags, please), but I suspect you would be better served reporting this to the Strawberry Perl people.

      Severity Code Description Project File Line Suppression State Warning C4244 '=': conversion from '__int64' to 'I32', possible loss of data C:\Strawberry\perl\lib\CORE\inline.h 2165

      Above is the warning we are getting.

      When you go to link 2165 of inline.h this is line of code: PL_curstackinfo->si_cxsubix = cx - PL_curstackinfo->si_cxstack; Looking at PL_curstackinfoyou get (from cop.h):

      struct stackinfo { AV * si_stack; /* stack for current + runlevel */ PERL_CONTEXT * si_cxstack; /* context stack for r +unlevel */ struct stackinfo * si_prev; struct stackinfo * si_next; I32 si_cxix; /* current conte +xt index */ I32 si_cxmax; /* m +aximum allocated index */ I32 si_cxsubix; /* to +pmost sub/eval/format */ I32 si_type; /* type of runle +vel */ I32 si_markoff; /* of +fset where markstack begins for us. + * currently used only with DEBUGGING, + * but not #ifdef-ed for bincompat */ #if defined DEBUGGING && !defined DEBUGGING_RE_ONLY /* high water mark: for checking if the stack was correctly extended / * tested for extension by each pp function */ SSize_t si_stack_hwm; #endif };

      Here we can see that si_sxsubix is defined as an I32 which is typdef long I32. si_cxstack is a pointer to a PERL_CONTEXT. The key here is the fact it’s a pointer.

      PERL_CONTEXT *cx

      Going back to the line of code that is getting the warning:

      PL_curstackinfo->si_cxsubix = cx - PL_curstackinfo->si_cxstack;

      cx is going to be the address to a PERL_CONTEXT The problem is that when compiling for 64bit systems an address is going to be 64bits so now when doing the subtraction and putting it into the 32bit si_cxsubix there’s a conversation issue because the 64bit subtraction is being put into a 32bit value.

        Thanks, that is a far clearer example; I've now reported this as Perl #20841.

Re: C4244 Warning in inline.h file while using Win64 configuration
by swl (Prior) on Feb 16, 2023 at 02:06 UTC
Re: C4244 Warning in inline.h file while using Win64 configuration
by haukex (Archbishop) on Feb 15, 2023 at 16:42 UTC
Re: C4244 Warning in inline.h file while using Win64 configuration
by Anonymous Monk on Feb 16, 2023 at 14:06 UTC
    Ignore it, no thing for you to do, there is a bajillion warnings