diff options
author | Father Chrysostomos <sprout@cpan.org> | 2013-08-19 16:16:37 -0700 |
---|---|---|
committer | Father Chrysostomos <sprout@cpan.org> | 2013-08-20 12:50:01 -0700 |
commit | 4f62cd62aef0fcb9cc527c8aea4d04423189cfd5 (patch) | |
tree | c5f774a31d7358f3dbe01cd0c384851692b8b550 /sv.c | |
parent | 85b0ee6ec41030ce5cff3c130bacafa371a14cb9 (diff) | |
download | perl-4f62cd62aef0fcb9cc527c8aea4d04423189cfd5.tar.gz |
[perl #118693] Remove PADTMP exemption from uninit warnings
This fixes a problem with undefined values return from XSUBs not pro-
ducing such warnings.
The default typemap for XSUBs uses the target of the entersub call (in
the caller’s pad) to return the converted value, instead of having to
allocate a new SV for that.
So, for example, a function returning char* will cause that char* to
be assigned to the target via sv_setpv. Then the target is returned.
As a special case, NULL return from a char*-returning function will
produce an undef return value. This undef return value was not trig-
gering an uninitialized warning.
All targets are marked PADTMP, and anything marked PADTMP is exempt
from uninitialized warnings in some code paths, but not others.
This goes all the way back to 91bba347, which suppressed the warning
with only a hit at why (something to do with bitwise ops warning inap-
propriately). I think it was to make ~undef exempt. But a1afd104
stopped it from being exempt.
Only a few pieces of code were relying on this exemption, and it was
hiding bugs, too. The last few commits have addressed those, so kiss
this exemption good-bye!
pp_reverse had a workaround to force an uninit warning (since
1e21d011c), so remove the workaround to avoid a double uninit warning.
Diffstat (limited to 'sv.c')
-rw-r--r-- | sv.c | 8 |
1 files changed, 3 insertions, 5 deletions
@@ -2274,10 +2274,8 @@ S_sv_2iuv_common(pTHX_ SV *const sv) if (isGV_with_GP(sv)) return glob_2number(MUTABLE_GV(sv)); - if (!SvPADTMP(sv)) { - if (!PL_localizing && ckWARN(WARN_UNINITIALIZED)) + if (!PL_localizing && ckWARN(WARN_UNINITIALIZED)) report_uninit(sv); - } if (SvTYPE(sv) < SVt_IV) /* Typically the caller expects that sv_any is not NULL now. */ sv_upgrade(sv, SVt_IV); @@ -2681,7 +2679,7 @@ Perl_sv_2nv_flags(pTHX_ SV *const sv, const I32 flags) return 0.0; } - if (!PL_localizing && !SvPADTMP(sv) && ckWARN(WARN_UNINITIALIZED)) + if (!PL_localizing && ckWARN(WARN_UNINITIALIZED)) report_uninit(sv); assert (SvTYPE(sv) >= SVt_NV); /* Typically the caller expects that sv_any is not NULL now. */ @@ -3025,7 +3023,7 @@ Perl_sv_2pv_flags(pTHX_ SV *const sv, STRLEN *const lp, const I32 flags) *lp = 0; if (flags & SV_UNDEF_RETURNS_NULL) return NULL; - if (!PL_localizing && !SvPADTMP(sv) && ckWARN(WARN_UNINITIALIZED)) + if (!PL_localizing && ckWARN(WARN_UNINITIALIZED)) report_uninit(sv); /* Typically the caller expects that sv_any is not NULL now. */ if (!SvREADONLY(sv) && SvTYPE(sv) < SVt_PV) |