@@ -4275,24 +4275,17 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags)
4275
4275
SvREFCNT_dec(old_rv);
4276
4276
return;
4277
4277
}
4278
-
4278
+ /*
4279
4279
#if NVSIZE <= IVSIZE
4280
4280
both_type = (stype | dtype);
4281
4281
#endif
4282
-
4282
+ */
4283
4283
if (UNLIKELY(both_type == SVTYPEMASK)) {
4284
- if (SvIS_FREED(dsv)) {
4285
- Perl_croak(aTHX_ "panic: attempt to copy value %" SVf
4286
- " to a freed scalar %p", SVfARG(ssv), (void *)dsv);
4287
- }
4288
- if (SvIS_FREED(ssv)) {
4289
- Perl_croak(aTHX_ "panic: attempt to copy freed scalar %p to %p",
4290
- (void*)ssv, (void*)dsv);
4291
- }
4284
+ croak_sv_setsv_flags(dsv, ssv);
4285
+ NOT_REACHED;
4292
4286
}
4293
4287
4294
4288
4295
-
4296
4289
SV_CHECK_THINKFIRST_COW_DROP(dsv);
4297
4290
dtype = SvTYPE(dsv); /* THINKFIRST may have changed type */
4298
4291
@@ -4390,14 +4383,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags)
4390
4383
invlist_clone(ssv, dsv);
4391
4384
return;
4392
4385
default:
4393
- {
4394
- const char * const type = sv_reftype(ssv,0);
4395
- if (PL_op)
4396
- /* diag_listed_as: Bizarre copy of %s */
4397
- Perl_croak(aTHX_ "Bizarre copy of %s in %s", type, OP_DESC(PL_op));
4398
- else
4399
- Perl_croak(aTHX_ "Bizarre copy of %s", type);
4400
- }
4386
+ croak_sv_setsv_flags(dsv, ssv);
4401
4387
NOT_REACHED; /* NOTREACHED */
4402
4388
4403
4389
case SVt_REGEXP:
@@ -4451,12 +4437,8 @@ Perl_sv_setsv_flags(pTHX_ SV *dsv, SV* ssv, const I32 flags)
4451
4437
else if (UNLIKELY(dtype == SVt_PVAV || dtype == SVt_PVHV
4452
4438
|| dtype == SVt_PVFM))
4453
4439
{
4454
- const char * const type = sv_reftype(dsv,0);
4455
- if (PL_op)
4456
- /* diag_listed_as: Cannot copy to %s */
4457
- Perl_croak(aTHX_ "Cannot copy to %s in %s", type, OP_DESC(PL_op));
4458
- else
4459
- Perl_croak(aTHX_ "Cannot copy to %s", type);
4440
+ croak_sv_setsv_flags(dsv, ssv);
4441
+ NOT_REACHED;
4460
4442
} else if (sflags & SVf_ROK) {
4461
4443
if (isGV_with_GP(dsv)
4462
4444
&& SvTYPE(SvRV(ssv)) == SVt_PVGV && isGV_with_GP(SvRV(ssv))) {
@@ -17736,6 +17718,44 @@ Perl_report_uninit(pTHX_ const SV *uninit_sv)
17736
17718
GCC_DIAG_RESTORE_STMT;
17737
17719
}
17738
17720
17721
+ /* This helper function for Perl_sv_setsv_flags is as cold as they come.
17722
+ * We should almost never call it and it will definitely croak when we do.
17723
+ * Therefore it should not matter that it is not close to the main function
17724
+ * or that we make it redo work that the caller already did.
17725
+ * The main aim is to keep Perl_sv_setsv_flags as slim as possible and this
17726
+ * includes keeping the call sites for this function small.
17727
+ */
17728
+ void S_croak_sv_setsv_flags(pTHX_ SV * const dsv, SV * const ssv)
17729
+ {
17730
+ OP *op = PL_op;
17731
+ if (SvIS_FREED(dsv)) {
17732
+ Perl_croak(aTHX_ "panic: attempt to copy value %" SVf
17733
+ " to a freed scalar %p", SVfARG(ssv), (void *)dsv);
17734
+ }
17735
+ if (SvIS_FREED(ssv)) {
17736
+ Perl_croak(aTHX_ "panic: attempt to copy freed scalar %p to %p",
17737
+ (void*)ssv, (void*)dsv);
17738
+ }
17739
+
17740
+ if (SvTYPE(ssv) > SVt_PVLV)
17741
+ {
17742
+ const char * const type = sv_reftype(ssv,0);
17743
+ if (op)
17744
+ /* diag_listed_as: Bizarre copy of %s */
17745
+ Perl_croak(aTHX_ "Bizarre copy of %s in %s", type, OP_DESC(op));
17746
+ else
17747
+ Perl_croak(aTHX_ "Bizarre copy of %s", type);
17748
+ }
17749
+
17750
+ const char * const type = sv_reftype(dsv,0);
17751
+ if (op)
17752
+ /* diag_listed_as: Cannot copy to %s */
17753
+ Perl_croak(aTHX_ "Cannot copy to %s in %s", type, OP_DESC(op));
17754
+ else
17755
+ Perl_croak(aTHX_ "Cannot copy to %s", type);
17756
+
17757
+ }
17758
+
17739
17759
/*
17740
17760
* ex: set ts=8 sts=4 sw=4 et:
17741
17761
*/
0 commit comments