Perl_croak(aTHX_ "Illegal number of bits in vec");
if (SvUTF8(sv)) {
- (void) Perl_sv_utf8_downgrade(aTHX_ sv, TRUE);
- /* PVX may have changed */
- s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags);
+ if (Perl_sv_utf8_downgrade(aTHX_ sv, TRUE)) {
+ /* PVX may have changed */
+ s = (unsigned char *) SvPV_flags(sv, srclen, svpv_flags);
+ }
+ else {
+ Perl_ck_warner_d(aTHX_ packWARN(WARN_DEPRECATED),
+ "Use of strings with code points over 0xFF as"
+ " arguments to vec is deprecated. This will"
+ " be a fatal error in Perl 5.32");
+ }
}
if (size < 8) {
STRLEN targlen;
STRLEN len;
SV * const targ = LvTARG(sv);
+ char errflags = LvFLAGS(sv);
PERL_ARGS_ASSERT_DO_VECSET;
+ /* some out-of-range errors have been deferred if/until the LV is
+ * actually written to: f(vec($s,-1,8)) is not always fatal */
+ if (errflags) {
+ assert(!(errflags & ~(LVf_NEG_OFF|LVf_OUT_OF_RANGE)));
+ if (errflags & LVf_NEG_OFF)
+ Perl_croak_nocontext("Negative offset to vec in lvalue context");
+ Perl_croak_nocontext("Out of memory!");
+ }
+
if (!targ)
return;
s = (unsigned char*)SvPV_force_flags(targ, targlen,