sv.c: !SvLEN does not mean undefined
authorFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 06:30:28 +0000 (23:30 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sun, 28 Oct 2012 09:04:57 +0000 (02:04 -0700)
commitcd84013aab030da47b76a44fb3f7b6016be85b78
tree0310735e26cc23a0f1991ab83c8d427f4fd5cf83
parent78a84e43f7c23daa5ea308f75bfa99ce0fd2a841
sv.c: !SvLEN does not mean undefined

There are various SvPOKp(sv) && SvLEN(sv) checks in numeric
conversion routines in sv.c, which date back to perl 1.  (See
<http://perl5.git.perl.org/perl.git/blob/8d063cd8450e59e:/str.c#l89>.)
Back then it did not matter, as str->len (later SvLEN) was always set
when there was a PV.  It was not until perl 5.003_01 (1edc1566d5) that
we got the SvLEN==0 mechanism for PVs not owned by the scalar.  (I
don’t believe it was actually used till later, so when this became a
problem I don’t know--but that’s enough digging.)

A regexp returned by ${qr//} is POK but does not own its string.  This
means that nummifying a regexp will result in a uninitialized warning.

The SvLEN check is redundant and problematic, so I am removing it.
(This also means I can remove the sv_force_normal calls in the next
commit, since shared hash key scalars, which also have SvLEN==0 will
no longer need it to pass the SvLEN checks.)

This does mean, however, that SVt_REGEXP can reach code paths that
expect to be able to use Sv[IN]VX (not valid for regexps), so I actu-
ally have to check that the type != SVt_REGEXP as well.  We already
have code for handling fbm scalars (for which Sv[IN]VX fields are also
unusable), so we can send regexps through those paths.
sv.c
t/lib/warnings/9uninit