From: Father Chrysostomos Date: Wed, 6 Apr 2011 19:40:44 +0000 (-0700) Subject: [perl #87708] $tied + $tied and $tied - $tied under ‘use integer’ X-Git-Tag: accepted/trunk/20130322.191538~4476 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e62ca0f9ce708db51e000573ffdc696e61eabdf7;p=platform%2Fupstream%2Fperl.git [perl #87708] $tied + $tied and $tied - $tied under ‘use integer’ This is just part of #87708. This fixes + and - under ‘use integer’ when the same tied scalar 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 + just worked but the operands were swapped for -. --- diff --git a/pp.h b/pp.h index e676e04..80ebfe6 100644 --- a/pp.h +++ b/pp.h @@ -355,9 +355,10 @@ Does not use C. See also C, C and C. SV *leftsv = CAT2(X,s); \ IV left = USE_LEFT(leftsv) ? SvIV(leftsv) : 0 #define dPOPXiirl_ul_nomg(X) \ - IV right = POPi; \ + SV *rightsv = POPs; \ SV *leftsv = CAT2(X,s); \ - IV left = USE_LEFT(leftsv) ? SvIV_nomg(leftsv) : 0 + IV left = USE_LEFT(leftsv) ? SvIV_nomg(leftsv) : 0; \ + IV right = SvIV(rightsv) #define dPOPPOPssrl dPOPXssrl(POP) #define dPOPPOPnnrl dPOPXnnrl(POP) diff --git a/t/lib/warnings/9uninit b/t/lib/warnings/9uninit index 7dfeb7b..d634846 100644 --- a/t/lib/warnings/9uninit +++ b/t/lib/warnings/9uninit @@ -556,10 +556,10 @@ $v = $m1 != $g1; $v = $m1 <=> $g1; $v = -$m1; EXPECT -Use of uninitialized value $g1 in integer addition (+) at - line 6. Use of uninitialized value $m1 in integer addition (+) at - line 6. -Use of uninitialized value $g1 in integer subtraction (-) at - line 7. +Use of uninitialized value $g1 in integer addition (+) at - line 6. Use of uninitialized value $m1 in integer subtraction (-) at - line 7. +Use of uninitialized value $g1 in integer subtraction (-) at - line 7. Use of uninitialized value $g1 in integer multiplication (*) at - line 8. Use of uninitialized value $m1 in integer multiplication (*) at - line 8. Use of uninitialized value $g1 in integer division (/) at - line 9. diff --git a/t/op/tie_fetch_count.t b/t/op/tie_fetch_count.t index d0a3b62..79c9015 100644 --- a/t/op/tie_fetch_count.t +++ b/t/op/tie_fetch_count.t @@ -232,20 +232,9 @@ bin_test '.' , 1, 2, 12; bin_int_test '*' , 2, 3, 6; bin_int_test '/' , 10, 2, 5; bin_int_test '%' , 11, 2, 1; - # For these two, one of the tests in bin_int_test passes and the other - # fails, so we spell them out for now. - #bin_int_test '+' , 1, 2, 3; - #bin_int_test '-' , 11, 2, 9; - { - use integer; - tie my $var, "main", 1, 2; - is($var + $var, 3, 'retval of $var + $var under use integer'); - { local $TODO; check_count '+ under use integer', 2; } - tie $var, "main", 11, 2; - is($var - $var, 9, 'retval of $var - $var under use integer'); - { local $TODO; check_count '- under use integer', 2; } - } } +bin_int_test '+' , 1, 2, 3; +bin_int_test '-' , 11, 2, 9; bin_int_test '<' , 1, 2, 1; bin_int_test '>' , 44, 2, 1; bin_int_test '<=', 44, 2, "";