SvPV acting as a prototype placeholder to a full typeglob.
p4raw-id: //depot/perl@27336
{
dVAR;
register GP *gp;
- const bool doproto = SvTYPE(gv) > SVt_NULL;
+ const U32 old_type = SvTYPE(gv);
+ const bool doproto = old_type > SVt_NULL;
const char * const proto = (doproto && SvPOK(gv)) ? SvPVX_const(gv) : NULL;
SV *const has_constant = doproto && SvROK(gv) ? SvRV(gv) : NULL;
SvROK_off(gv);
}
- sv_upgrade((SV*)gv, SVt_PVGV);
+
+ if (old_type < SVt_PVGV) {
+ if (old_type >= SVt_PV)
+ SvCUR_set(gv, 0);
+ sv_upgrade((SV*)gv, SVt_PVGV);
+ }
if (SvLEN(gv)) {
if (proto) {
SvPV_set(gv, NULL);