This is just part of #87708.
This fixes the / operator under ‘use integer’ when the same tied sca-
lar is used for both operands and returns two different values. Before
this commit, get-magic would be called only once and the same value
used. In 5.12.x the operands were swapped.
PP(pp_i_divide)
{
- IV num;
dVAR; dSP; dATARGET;
tryAMAGICbin_MG(div_amg, AMGf_assign);
{
dPOPTOPssrl;
- IV value = SvIV_nomg(right);
+ IV num = SvIV_nomg(left);
+ IV value = left==right ? SvIV(right) : SvIV_nomg(right);
if (value == 0)
DIE(aTHX_ "Illegal division by zero");
- num = SvIV_nomg(left);
/* avoid FPE_INTOVF on some platforms when num is IV_MIN */
if (value == -1)
Use of uninitialized value $g1 in integer subtraction (-) at - line 7.
Use of uninitialized value $m1 in integer multiplication (*) at - line 8.
Use of uninitialized value $g1 in integer multiplication (*) at - line 8.
+Use of uninitialized value $m1 in integer division (/) at - line 9.
Use of uninitialized value $g1 in integer division (/) at - line 9.
Use of uninitialized value $m2 in integer division (/) at - line 10.
Use of uninitialized value $m1 in integer modulus (%) at - line 11.
bin_test '+' , 1, 2, 3;
}
bin_int_test '*' , 2, 3, 6;
-{
- local $TODO = $todo ;
- bin_int_test '/' , 10, 2, 5;
-}
+bin_int_test '/' , 10, 2, 5;
bin_int_test '%' , 11, 2, 1;
bin_int_test '+' , 1, 2, 3;
bin_int_test '-' , 11, 2, 9;