summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2021-07-04 19:23:05 +0000
committerNicholas Clark <nick@ccl4.org>2022-02-19 19:46:37 +0000
commit59cc2f5b2548d81765e9f3dc2ce10c1070e787b8 (patch)
treeec8d7cdf97a60470fe38ebcf0fcbbed90a61626b
parentcff76435bba3c0cf32c22b33ad9f14672094c90b (diff)
downloadperl-59cc2f5b2548d81765e9f3dc2ce10c1070e787b8.tar.gz
Copy values that are "written as IV, then read as PV" with the same flags.
Previously Perl_sv_setsv_flags() would gleefully turn on SVf_POK for these values, which meant that any copy no longer propagated the (new) state that says "this value started as an integer".
-rw-r--r--sv.c6
1 files changed, 6 insertions, 0 deletions
diff --git a/sv.c b/sv.c
index 3537a33a78..fb206a7347 100644
--- a/sv.c
+++ b/sv.c
@@ -4892,6 +4892,12 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags)
SvIV_set(dsv, SvIVX(ssv));
if (sflags & SVf_IVisUV)
SvIsUV_on(dsv);
+ if ((sflags & SVf_IOK) && !(sflags & SVf_POK)) {
+ /* Source was SVf_IOK|SVp_IOK|SVp_POK but not SVf_POK, meaning
+ a value set as an integer and later stringified. So mark
+ destination the same: */
+ SvFLAGS(dsv) &= ~SVf_POK;
+ }
}
SvFLAGS(dsv) |= sflags & (SVf_IOK|SVp_IOK|SVf_NOK|SVp_NOK|SVf_UTF8);
{