|Date:||Fri, 17 Feb 2017 09:53:09 +0100|
|From:||pali [...] cpan.org|
|Subject:||SvNV() does not store computed value to NV slot|
|To:||perlbug [...] perl.org|
When sv is non-magic PV type then functions SvIV(), SvUV() and SvNV() upgrade sv to type which has slot for also for IV/UV/NV type and store converted value to that slot. When sv is magic PV type then function SvIV() and SvUV() do it too. But SvNV() does not upgrade sv if is magical. And converted value is just returned, not stored to sv. It is in function Perl_sv_2nv_flags() (called by SvNV() on sv of PV type). If sv is SvGMAGICAL() and has SvPOKp() flag then just Atof() value is returned and not stored back to sv. When sv is not magical then sv_upgrade() and SvNV_set(sv, Atof(SvPVX_const(sv))) are called. On the other hand Perl_sv_2iv_flags() (called by SvIV()) calls S_sv_2iuv_common() for converting and upgrading PV to IV when sv is and also is not magical. Same apply for Perl_sv_2uv_flags(). So is there reason why SvNV() behave differently for magic scalars? Or it is bug and SvNV should do similar things as SvIV/SvUV or as SvNV on non-magical scalars?