Skip to content

Commit 8e4fb95

Browse files
committed
inline.h: fix conversion warnings under MSVC
The following warnings show up repeatedly when building with MSVC: D:\a\perl5\perl5\inline.h(1147): warning C4018: '<=': signed/unsigned mismatch D:\a\perl5\perl5\inline.h(3946): warning C4244: '=': conversion from '__int64' to 'I32', possible loss of data This patch should silence them without a change in functionality.
1 parent a634b79 commit 8e4fb95

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

cop.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1302,7 +1302,13 @@ typedef struct stackinfo PERL_SI;
13021302

13031303
#ifdef DEBUGGING
13041304
# define SET_MARK_OFFSET \
1305-
PL_curstackinfo->si_markoff = PL_markstack_ptr - PL_markstack
1305+
STMT_START { \
1306+
/* ensure .si_markoff is an I32 and can hold the pointer difference */ \
1307+
STATIC_ASSERT_STMT(sizeof PL_curstackinfo->si_markoff == sizeof (I32)); \
1308+
assert(PL_markstack_ptr >= PL_markstack); \
1309+
assert(PL_markstack_ptr - PL_markstack <= (ptrdiff_t)I32_MAX); \
1310+
PL_curstackinfo->si_markoff = (I32)(PL_markstack_ptr - PL_markstack); \
1311+
} STMT_END
13061312
#else
13071313
# define SET_MARK_OFFSET NOOP
13081314
#endif

inline.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1144,9 +1144,9 @@ Perl_rpp_is_lone(pTHX_ SV *sv)
11441144
assert(AvREAL(PL_curstack));
11451145
#endif
11461146

1147-
return SvREFCNT(sv) <= cBOOL(SvTEMP(sv))
1147+
return SvREFCNT(sv) <= (U32)cBOOL(SvTEMP(sv))
11481148
#ifdef PERL_RC_STACK
1149-
+ 1
1149+
+ 1u
11501150
&& !SvIMMORTAL(sv) /* PL_sv_undef etc are never stealable */
11511151
#endif
11521152
;

0 commit comments

Comments
 (0)