summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2016-01-19 15:19:48 +0000
committerDavid Mitchell <davem@iabyn.com>2016-01-19 15:19:48 +0000
commit3c84a230ed64f5ef68617ef355b5b35bf93a3951 (patch)
tree5f9c8b4bd197ff1c3f8731f3c5648177c9d6617c /t
parent88e8953ab73a4d30082802322680035722e28de9 (diff)
downloadperl-3c84a230ed64f5ef68617ef355b5b35bf93a3951.tar.gz
remove vestigial uses of PRIVSHIFT
This is a hangover from when a magic (e.g. tied) var, after calling mg_get(), would only set the private (SVp_IOK,SVp_NOK,SVp_POK) flags on the result, indicating that although it now had a valid integer value (say), it wasn't a "real" integer. This was achieved by, after calling mg_get(), shifting all the public flags by PRIVSHIFT to convert them to private flags. Since 5.18.0, that's not been the case (i.e. mg_get() on a tied var leaves Svf_IOK etc set). But there are still a couple of vestigial uses of PRIVSHIFT in the core, and this commit removes them. For one of them, I added a test that shows that (in slightly contrived circumnstances), it was possible for a SVp_IOK NV to be upgraded to a SVf_IOK int on return from localisation, losing its fractional component. The other one, in S_sv_unmagicext_flags(), only seemed to get called when setting a new value (e.g. from mg_set()), so its unlikely that such a var would still have private flags set that could be incorrectly upgraded to public.
Diffstat (limited to 't')
-rw-r--r--t/op/taint.t15
1 files changed, 14 insertions, 1 deletions
diff --git a/t/op/taint.t b/t/op/taint.t
index eaee77a5a5..101c6da427 100644
--- a/t/op/taint.t
+++ b/t/op/taint.t
@@ -17,7 +17,7 @@ BEGIN {
use strict;
use Config;
-plan tests => 807;
+plan tests => 808;
$| = 1;
@@ -2378,6 +2378,19 @@ is eval { eval $::x.1 }, 1, 'reset does not taint undef';
is_tainted $n3, "* SETn";
}
+# check that localizing something with get magic (e.g. taint) doesn't
+# upgrade pIOK to IOK
+
+{
+ local our $x = 1.1 + $TAINT0; # $x should be NOK
+ my $ix = int($x); # now NOK, pIOK
+ {
+ local $x = 0;
+ }
+ my $x1 = $x * 1;
+ isnt($x, 1); # it should be 1.1, not 1
+}
+
# This may bomb out with the alarm signal so keep it last
SKIP: {