File tree Expand file tree Collapse file tree 2 files changed +21
-16
lines changed Expand file tree Collapse file tree 2 files changed +21
-16
lines changed Original file line number Diff line number Diff line change @@ -1919,7 +1919,7 @@ PP(pp_subtract)
19191919
19201920 SV * svr = PL_stack_sp [0 ];
19211921 SV * svl = PL_stack_sp [-1 ];
1922-
1922+ NV nv ;
19231923
19241924#ifdef PERL_PRESERVE_IVUV
19251925
@@ -2050,7 +2050,8 @@ PP(pp_subtract)
20502050 TARGi (NEGATE_2IV (result ), 1 );
20512051 else {
20522052 /* result valid, but out of range for IV. */
2053- TARGn (- (NV )result , 1 );
2053+ nv = - (NV )result ;
2054+ goto ret_nv ;
20542055 }
20552056 }
20562057 goto ret ;
@@ -2060,13 +2061,14 @@ PP(pp_subtract)
20602061#else
20612062 useleft = USE_LEFT (svl );
20622063#endif
2063- {
2064- /* If left operand is undef, treat as zero - value */
2065- NV value = useleft ? SvNV_nomg (svl ) : 0.0 ;
2066- value -= SvNV_nomg (svr );
2067- TARGn (value , 1 );
2068- goto ret ;
2069- }
2064+
2065+ /* If left operand is undef, treat as zero - value */
2066+ nv = useleft ? SvNV_nomg (svl ) : 0.0 ;
2067+ /* Separate statements here to ensure SvNV_nomg(svl) is evaluated
2068+ before SvNV_nomg(svr) */
2069+ nv -= SvNV_nomg (svr );
2070+ ret_nv :
2071+ TARGn (nv , 1 );
20702072
20712073 ret :
20722074 rpp_replace_2_1_NN (targ );
Original file line number Diff line number Diff line change @@ -1811,6 +1811,7 @@ PP(pp_add)
18111811 SV * targ = (PL_op -> op_flags & OPf_STACKED )
18121812 ? PL_stack_sp [-1 ]
18131813 : PAD_SV (PL_op -> op_targ );
1814+ NV nv ;
18141815
18151816 if (rpp_try_AMAGIC_2 (add_amg , AMGf_assign |AMGf_numeric ))
18161817 return NORMAL ;
@@ -1994,7 +1995,8 @@ PP(pp_add)
19941995 TARGi (NEGATE_2IV (result ), 1 );
19951996 else {
19961997 /* result valid, but out of range for IV. */
1997- TARGn (- (NV )result , 1 );
1998+ nv = - (NV )result ;
1999+ goto ret_nv ;
19982000 }
19992001 }
20002002 goto ret ;
@@ -2006,12 +2008,13 @@ PP(pp_add)
20062008 useleft = USE_LEFT (svl );
20072009#endif
20082010
2009- {
2010- /* If left operand is undef, treat as zero. */
2011- NV value = useleft ? SvNV_nomg (svl ) : 0.0 ;
2012- value += SvNV_nomg (svr );
2013- TARGn (value , 1 );
2014- }
2011+ /* If left operand is undef, treat as zero. */
2012+ nv = useleft ? SvNV_nomg (svl ) : 0.0 ;
2013+ /* Separate statements here to ensure SvNV_nomg(svl) is evaluated
2014+ before SvNV_nomg(svr) */
2015+ nv += SvNV_nomg (svr );
2016+ ret_nv :
2017+ TARGn (nv , 1 );
20152018
20162019 ret :
20172020 rpp_replace_2_1_NN (targ );
You can’t perform that action at this time.
0 commit comments