This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
import perl5177delta content to perl5180delta
[perl5.git] / Porting / perl5180delta.pod
CommitLineData
e5ba1bf1
FC
1=encoding utf8
2
3=head1 NAME
4
0bba4573 5perl5180delta - what is new for perl v5.18.0
e5ba1bf1
FC
6
7=head1 DESCRIPTION
8
0bba4573 9This document describes differences between the 5.16.0 release and the 5.18.0
e5ba1bf1
FC
10release.
11
0bba4573
RS
12If you are upgrading from an earlier release such as 5.14.0, first read
13L<perl5140delta>, which describes differences between 5.12.0 and 5.14.0.
e5ba1bf1
FC
14
15=head1 Notice
16
17XXX Any important notices here
18
19=head1 Core Enhancements
20
7e7c78a1
RS
21=head2 Character name aliases may now include non-Latin1-range characters
22
23It is possible to define your own names for characters for use in
24C<\N{...}>, C<charnames::vianame()>, etc. These names can now be
25comprised of characters from the whole Unicode range. This allows for
26names to be in your native language, and not just English. Certain
27restrictions apply to the characters that may be used (you can't define
28a name that has punctuation in it, for example). See L<charnames/CUSTOM
29ALIASES>.
30
31=head2 New hash function Murmurhash-32 (v3)
32
33We have switched Perl's hash function to use Murmurhash-32, and added build
34support for several other hash functions. This new function is expected to
35perform equivalently to the old one for shorter strings and is faster,
36potentially twice as fast, for hashing longer strings.
37
f7b06e7f 38=head2 Upgrade to Unicode 6.2
00785cb7 39
f7b06e7f
RS
40Perl now supports the final version of Unicode 6.2. Earlier releases in
41the 5.17 series supported Unicode 6.2 beta versions. There were no
42substantive changes in the final Unicode 6.2 version from the most
43recent beta, included in Perl 5.17.4. A list of changes from Unicode
446.1 is at L<http://www.unicode.org/versions/Unicode6.2.0>.
00785cb7
RS
45
46=head2 New DTrace probes
47
48The following new DTrace probes have been added:
49
50=over 4
51
52=item C<op-entry>
53
54=item C<loading-file>
55
56=item C<loaded-file>
57
58=back
59
60=head2 C<${^LAST_FH}>
61
62This new variable provides access to the filehandle that was last read.
63This is the handle used by C<$.> and by C<tell> and C<eof> without
64arguments.
65
66=head2 Looser here-doc parsing
67
68Here-doc terminators no longer require a terminating newline character when
69they occur at the end of a file. This was already the case at the end of a
70string eval [perl #65838].
71
72=head2 New mechanism for experimental features
73
74Newly-added experimental features will now require this incantation:
75
76 no warnings "experimental:feature_name";
77 use feature "feature_name"; # would warn without the prev line
78
79There is a new warnings category, called "experimental", containing
80warnings that the L<feature> pragma emits when enabling experimental
81features.
82
83Newly-added experimental features will also be given special warning IDs,
84which consist of "experimental:" followed by the name of the feature. (The
85plan is to extend this mechanism eventually to all warnings, to allow them
86to be enabled or disabled individually, and not just by category.)
87
88By saying
89
90 no warnings "experimental:feature_name";
91
92you are taking responsibility for any breakage that future changes to, or
93removal of, the feature may cause.
94
95=head2 Lexical subroutines
96
97This new feature is still considered experimental. To enable it, use the
98mechanism described above:
99
100 use 5.018;
101 no warnings "experimental:lexical_subs";
102 use feature "lexical_subs";
103
104You can now declare subroutines with C<state sub foo>, C<my sub foo>, and
105C<our sub foo>. (C<state sub> requires that the "state" feature be
106enabled, unless you write it as C<CORE::state sub foo>.)
107
108C<state sub> creates a subroutine visible within the lexical scope in which
109it is declared. The subroutine is shared between calls to the outer sub.
110
111C<my sub> declares a lexical subroutine that is created each time the
112enclosing block is entered. C<state sub> is generally slightly faster than
113C<my sub>.
114
115C<our sub> declares a lexical alias to the package subroutine of the same
116name.
117
118See L<perlsub/Lexical Subroutines>.
119
94b31d3f
RS
120=head2 Computed Labels
121
122The loop controls C<next>, C<last> and C<redo>, and the special C<dump>
123operator, now allow arbitrary expressions to be used to compute labels at run
124time. Previously, any argument that was not a constant was treated as the
125empty string.
126
0fef449b
RS
127=head2 More CORE:: subs
128
129Several more built-in functions have been added as subroutines to the
130CORE:: namespace, namely, those non-overridable keywords that can be
131implemented without custom parsers: C<defined>, C<delete>, C<exists>,
132C<glob>, C<pos>, C<protoytpe>, C<scalar>, C<split>, C<study>, and C<undef>.
133
134As some of these have prototypes, C<prototype('CORE::...')> has been
135changed to not make a distinction between overridable and non-overridable
136keywords. This is to make C<prototype('CORE::pos')> consistent with
137C<prototype(&CORE::pos)>.
e5ba1bf1 138
37133b20
RS
139=head2 C<kill> with negative signal names
140
141C<kill> has always allowed a negative signal number, which kills the
142process group instead of a single process. It has also allowed signal
143names. But it did not behave consistently, because negative signal names
144were treated as 0. Now negative signals names like C<-INT> are supported
145and treated the same way as -2 [perl #112990].
146
147=head2 C<pack> is now constant folded.
148
149C<pack> with constant arguments is now constant folded in most cases
150[perl #113470].
e5ba1bf1
FC
151
152=head1 Security
153
d268df4d
RS
154=head2 C<Storable> security warning in documentation
155
156The documentation for C<Storable> now includes a section which warns readers
157of the danger of accepting Storable documents from untrusted sources. The
158short version is that deserializing certain types of data can lead to loading
159modules and other code execution. This is documented behavior and wanted
160behavior, but this opens an attack vector for malicious entities.
161
162=head2 C<Locale::Maketext> allowed code injection via a malicious template
163
164If users could provide a translation string to Locale::Maketext, this could be
165used to invoke arbitrary Perl subroutines available in the current process.
166
167This has been fixed, but it is still possible to invoke any method provided by
168C<Locale::Maketext> itself or a subclass that you are using. One of these
169methods in turn will invoke the Perl core's C<sprintf> subroutine.
170
171In summary, allowing users to provide translation strings without auditing
172them is a bad idea.
173
174This vulnerability is documented in CVE-2012-6329.
175
7e7c78a1
RS
176=head2 An unknown character name in C<\N{...}> is now a syntax error
177
178Previously, it warned, and the Unicode REPLACEMENT CHARACTER was
179substituted. Unicode now recommends that this situation be a syntax
180error. Also, the previous behavior led to some confusing warnings and
181behaviors, and since the REPLACEMENT CHARACTER has no use other than as
182a stand-in for some unknown character, any code that has this problem is
183buggy.
184
185=head2 Formerly deprecated characters in C<\N{}> character name aliases are now errors.
186
187Since v5.12.0, it has been deprecated to use certain characters in
188user-defined C<\N{...}> character names. These now cause a syntax
189error. For example, it is now an error to begin a name with a digit,
190such as in
191
192 my $undraftable = "\N{4F}"; # Syntax error!
193
194or to have commas anywhere in the name. See L<charnames/CUSTOM ALIASES>
195
196=head2 Per process hash randomization
197
198The seed used by Perl's hash function is now random. This means that the
199order which keys/values will be returned from functions like C<keys()>,
200C<values()>, and C<each()> will differ from run to run.
201
202This change was introduced to make Perl's hashes more robust to algorithmic
203complexity attacks, and also because we discovered that it exposes hash
204ordering dependency bugs and makes them easier to track down.
205
206Toolchain maintainers might want to invest in additional infrastructure to
207test for things like this. Running tests several times in a row and then
208comparing results will make it easier to spot hash order dependencies in
209code. Authors are strongly encouraged not to expose the key order of
210Perl's hashes to insecure audiences.
211
212=head2 PERL_HASH_SEED enviornment variable now takes a hex value
213
214PERL_HASH_SEED no longer accepts an integer as a parameter, instead the
215value is expected to be a binary string encoded in hex. This is to make
216the infrastructure support hash seeds of arbitrary lengths which might
217exceed that of an integer. (SipHash uses a 16 byte seed).
218
219=head2 Hash::Util::hash_seed() now returns a string
220
221Hash::Util::hash_seed() now returns a string instead of an integer. This
222is to make the infrastructure support hash seeds of arbitrary lengths
223which might exceed that of an integer. (SipHash uses a 16 byte seed).
224
225=head2 Output of PERL_HASH_SEED_DEBUG has been changed
226
227The environment variable PERL_HASH_SEED_DEBUG now shows both the hash
228function perl was built with AND the seed, in hex in use for that process.
229Code parsing this output, should it exist, must change to accomodate the
230new format. Example of the new format:
231
232 $ PERL_HASH_SEED_DEBUG=1 ./perl -e1
233 HASH_FUNCTION = MURMUR3 HASH_SEED = 0x1476bb9f
234
f7b06e7f
RS
235=head2 Avoid calling memset with a negative count
236
237Poorly written perl code that allows an attacker to specify the count to perl's
238C<x> string repeat operator can already cause a memory exhaustion
239denial-of-service attack. A flaw in versions of perl before 5.15.5 can escalate
240that into a heap buffer overrun; coupled with versions of glibc before 2.16, it
241possibly allows the execution of arbitrary code.
e5ba1bf1 242
f7b06e7f 243The flaw addressed to this commit has been assigned identifier CVE-2012-5195.
e5ba1bf1
FC
244
245=head1 Incompatible Changes
246
d268df4d
RS
247=head2 Lexical $_ is now deprecated
248
249Since it was introduced in Perl 5.10, it has caused much confusion with no
250obvious solution:
251
252=over
253
254=item *
255
256Various modules (e.g., List::Util) expect callback routines to use the
257global $_. C<use List::Util 'first'; my $_; first { $_ == 1 } @list> does
258not work as one would expect.
259
260=item *
261
262A C<my $_> declaration earlier in the same file can cause confusing closure
263warnings.
264
265=item *
266
267The "_" subroutine prototype character allows called subroutines to access
268your lexical $_, so it is not really private after all.
269
270=item *
271
272Nevertheless, subroutines with a "(@)" prototype and methods cannot access
273the caller's lexical $_, unless they are written in XS.
274
275=item *
276
277But even XS routines cannot access a lexical $_ declared, not in the
278calling subroutine, but in an outer scope, iff that subroutine happened not
279to mention $_ or use any operators that default to $_.
280
281=back
282
283=head2 readline() with C<$/ = \N> now reads N characters, not N bytes
284
285Previously, when reading from a stream with I/O layers such as
286C<encoding>, the readline() function, otherwise known as the C<< <> >>
287operator, would read I<N> bytes from the top-most layer. [perl #79960]
288
289Now, I<N> characters are read instead.
290
291There is no change in behaviour when reading from streams with no
292extra layers, since bytes map exactly to characters.
293
294=head2 Lexical subroutine warnings have moved
295
296The warning about the use of an experimental feature emitted when lexical
297subroutines (added in 5.17.4) are used now happens when the subroutine
298itself is declared, not when the "lexical_subs" feature is activated via
299C<use feature>.
300
301This stops C<use feature ':all'> from warning, but causes
302C<my sub foo; my sub bar> to warn twice.
303
304=head2 Overridden C<glob> is now passed one argument
305
306C<glob> overrides used to be passed a magical undocumented second argument
307that identified the caller. Nothing on CPAN was using this, and it got in
308the way of a bug fix, so it was removed. If you really need to identify
309the caller, see L<Devel::Callsite> on CPAN.
310
f7b06e7f
RS
311=head2 New Restrictions in Multi-Character Case-Insensitive Matching in Regular Expression Bracketed Character Classes
312
313Unicode has now withdrawn their previous recommendation for regular
314expressions to automatically handle cases where a single character can
315match multiple characters case-insensitively; for example, the letter
316LATIN SMALL LETTER SHARP S and the sequence C<ss>. This is because
317it turns out to be impracticable to do this correctly in all
318circumstances. Because Perl has tried to do this as best it can, it
319will continue to do so. (We are considering an option to turn it off.)
320However, a new restriction is being added on such matches when they
321occur in [bracketed] character classes. People were specifying
322things such as C</[\0-\xff]/i>, and being surprised that it matches the
323two character sequence C<ss> (since LATIN SMALL LETTER SHARP S occurs in
324this range). This behavior is also inconsistent with the using a
325property instead of a range: C<\p{Block=Latin1}> also includes LATIN
326SMALL LETTER SHARP S, but C</[\p{Block=Latin1}]/i> does not match C<ss>.
327The new rule is that for there to be a multi-character case-insensitive
328match within a bracketed character class, the character must be
329explicitly listed, and not as an end point of a range. This more
330closely obeys the Principle of Least Astonishment. See
331L<perlrecharclass/Bracketed Character Classes>. Note that a bug [perl
332#89774], now fixed as part of this change, prevented the previous
333behavior from working fully.
334
00785cb7
RS
335=head2 Here-doc parsing
336
337The body of a here-document inside a quote-like operator now always begins
338on the line after the "<<foo" marker. Previously, it was documented to
339begin on the line following the containing quote-like operator, but that
340was only sometimes the case [perl #114040].
341
342=head2 Stricter parsing of substitution replacement
343
344It is no longer possible to abuse the way the parser parses C<s///e> like
345this:
346
347 %_=(_,"Just another ");
348 $_="Perl hacker,\n";
349 s//_}->{_/e;print
350
351=head2 Interaction of lexical and default warnings
352
353Turning on any lexical warnings used first to disable all default warnings
354if lexical warnings were not already enabled:
355
356 $*; # deprecation warning
357 use warnings "void";
358 $#; # void warning; no deprecation warning
359
360Now, the debugging, deprecated, glob, inplace and malloc warnings
361categories are left on when turning on lexical warnings (unless they are
362turned off by C<no warnings>, of course).
363
364This may cause deprecation warnings to occur in code that used to be free
365of warnings.
366
367Those are the only categories consisting only of default warnings. Default
368warnings in other categories are still disabled by C<use warnings
369"category">, as we do not yet have the infrastructure for controlling
370individual warnings.
371
372=head2 C<state sub> and C<our sub>
373
374Due to an accident of history, C<state sub> and C<our sub> were equivalent
375to a plain C<sub>, so one could even create an anonymous sub with
376C<our sub { ... }>. These are now disallowed outside of the "lexical_subs"
377feature. Under the "lexical_subs" feature they have new meanings described
378in L<perlsub/Lexical Subroutines>.
379
380=head2 C<gv_fetchmeth_*> and SUPER
381
382The various C<gv_fetchmeth_*> XS functions used to treat a package whose
383named ended with ::SUPER specially. A method lookup on the Foo::SUPER
384package would be treated as a SUPER method lookup on the Foo package. This
385is no longer the case. To do a SUPER lookup, pass the Foo stash and the
386GV_SUPER flag.
387
94b31d3f
RS
388=head2 Defined values stored in environment are forced to byte strings
389
390A value stored in an environment variable has always been stringified. In this
391release, it is converted to be only a byte string. First, it is forced to be a
392only a string. Then if the string is utf8 and the equivalent of
393C<utf8::downgrade()> works, that result is used; otherwise, the equivalent of
394C<utf8::encode()> is used, and a warning is issued about wide characters
395(L</Diagnostics>).
396
397=head2 C<given> now aliases the global C<$_>
398
399Instead of assigning to an implicit lexical C<$_>, C<given> now makes the
400global C<$_> an alias for its argument, just like C<foreach>. However, it
401still uses lexical C<$_> if there is lexical C<$_> in scope (again, just like
402C<foreach>) [perl #114020].
403
0bba4573
RS
404=head2 qw(...) can no longer be used as parentheses
405
406C<qw> lists used to fool the parser into thinking they were always
407surrounded by parentheses. This permitted some surprising constructions
408such as C<foreach $x qw(a b c) {...}>, which should really be written
409C<foreach $x (qw(a b c)) {...}>. These would sometimes get the lexer into
410the wrong state, so they didn't fully work, and the similar C<foreach qw(a
411b c) {...}> that one might expect to be permitted never worked at all.
412
413This side effect of C<qw> has now been abolished. It has been deprecated
414since Perl 5.13.11. It is now necessary to use real parentheses
415everywhere that the grammar calls for them.
e5ba1bf1 416
0bba4573 417=head2 C<\s> in regular expressions now matches a Vertical Tab
e5ba1bf1 418
0bba4573 419[ XXX ]
e5ba1bf1 420
0fef449b
RS
421=head2 C</(?{})/> and C</(??{})/> have been heavily reworked
422
423The implementation of this feature has been almost completely rewritten.
424Although its main intent is to fix bugs, some behaviors, especially
425related to the scope of lexical variables, will have changed. This is
426described more fully in the L</Selected Bug Fixes> section.
427
428=head2 C<\N{BELL}> now refers to U+1F514 instead of U+0007
429
430Unicode 6.0 reused the name "BELL" for a different code point than it
431traditionally had meant. Since Perl v5.14, use of this name still
432referred to U+0007, but would raise a deprecation warning. Now, "BELL"
433refers to U+1F514, and the name for U+0007 is "ALERT". All the
434functions in L<charnames> have been correspondingly updated.
435
436=head2 Alphanumeric operators must now be separated from the closing
437delimiter of regular expressions
438
439You may no longer write something like:
440
441 m/a/and 1
442
443Instead you must write
444
445 m/a/ and 1
446
447with whitespace separating the operator from the closing delimiter of
448the regular expression. Not having whitespace has resulted in a
449deprecation warning since Perl v5.14.0.
450
451=head2 C<require> dies for unreadable files
452
453When C<require> encounters an unreadable file, it now dies. It used to
454ignore the file and continue searching the directories in @INC
455[perl #113422].
456
457=head2 Upgrade to the Unicode 6.2 beta
458
459Unicode 6.2 is proposing some changes that may very well break some CPAN
460modules. The timing of this nicely coincides with Perl's being early in the
461release cycle. This commit takes the current beta 6.2, adds the proposed
462changes that aren't yet in it, and subtracts the changes that would affect \X
463processing, as those turn out to have errors, and may have to be rethought.
464Unicode has been notified of these problems.
465
466This will allow us to gather data as to whether or not the proposed changes
467cause us problems. These will be presented to Unicode to aid in their final
468decision as to whether or not to go forward with the changes.
469
470These changes will be replaced by the final version of Unicode 6.2 before
4715.18.0 is released.
472
e5ba1bf1
FC
473=head1 Deprecations
474
d268df4d
RS
475=head2 Various XS-callable functions are now deprecated
476
477The following functions will be removed from a future version of Perl,
478and should not be used. With participating C compilers (e.g., gcc),
479compiling any file that uses any of these will generate a warning.
480These were not intended for public use; there are equivalent, faster,
481macros for most of them. See L<perlapi/Character classes>:
482C<is_uni_ascii>, C<is_uni_ascii_lc>, C<is_uni_blank>, C<is_uni_blank_lc>,
483C<is_uni_cntrl>, C<is_uni_cntrl_lc>, C<is_uni_idfirst_lc>, C<is_uni_space>,
484C<is_uni_space_lc>, C<is_uni_xdigit>, C<is_uni_xdigit_lc>, C<is_utf8_ascii>,
485C<is_utf8_blank>, C<is_utf8_cntrl>, C<is_utf8_idcont>, C<is_utf8_idfirst>,
486C<is_utf8_perl_space>, C<is_utf8_perl_word>, C<is_utf8_posix_digit>,
487C<is_utf8_space>, C<is_utf8_xdigit>. C<is_utf8_xidcont>, C<is_utf8_xidfirst>,
488C<to_uni_lower_lc>, C<to_uni_title_lc>, and C<to_uni_upper_lc>.
489
e5ba1bf1 490
e5ba1bf1
FC
491=head1 Performance Enhancements
492
7e7c78a1
RS
493=over 4
494
495=item *
e5ba1bf1 496
7e7c78a1
RS
497Lists of lexical variable declarations (C<my($x, $y)>) are now optimised
498down to a single op, and are hence faster than before.
e5ba1bf1 499
7e7c78a1
RS
500=item *
501
502A new C preprocessor define NO_TAINT_SUPPORT was added that, if set, disables
503Perl's taint support altogether. Using the -T or -t command line flags will
504cause a fatal error. Beware that both core tests as well as many a CPAN
505distribution's tests will fail with this change. On the upside, it provides
506a small performance benefit due to reduced branching.
507
508B<Do not enable this unless you know exactly what you are getting yourself
509into.>
e5ba1bf1
FC
510
511=item *
512
00785cb7
RS
513Speed up in regular expression matching against Unicode properties. The
514largest gain is for C<\X>, the Unicode "extended grapheme cluster". The
515gain for it is about 35% - 40%. Bracketed character classes, e.g.,
516C<[0-9\x{100}]> containing code points above 255 are also now faster.
517
518=item *
519
520On platforms supporting it, several former macros are now implemented as static
521inline functions. This should speed things up slightly on non-GCC platforms.
522
523=item *
524
525Apply the optimisation of hashes in boolean context, such as in C<if> or C<and>,
526to constructs in non-void context.
527
528=item *
529
530Extend the optimisation of hashes in boolean context to C<scalar(%hash)>,
531C<%hash ? ... : ...>, and C<sub { %hash || ... }>.
532
533=item *
534
535When making a copy of the string being matched against (so that $1, $& et al
536continue to show the correct value even if the original string is subsequently
537modified), only copy that substring of the original string needed for the
538capture variables, rather than copying the whole string.
539
540This is a big win for code like
541
542 $&;
543 $_ = 'x' x 1_000_000;
544 1 while /(.)/;
545
546Also, when pessimizing if the code contains C<$`>, C<$&> or C<$'>, record the
547presence of each variable separately, so that the determination of the substring
548range is based on each variable separately. So performance-wise,
549
550 $&; /x/
551
552is now roughly equivalent to
553
554 /(x)/
555
556whereas previously it was like
557
558 /^(.*)(x)(.*)$/
559
560and
561
562 $&; $'; /x/
563
564is now roughly equivalent to
565
566 /(x)(.*)$/
567
568etc.
569
00785cb7
RS
570=item *
571
0bba4573
RS
572Filetest ops manage the stack in a fractionally more efficient manner.
573
574=item *
575
576Globs used in a numeric context are now numerified directly in most cases,
577rather than being numerified via stringification.
e5ba1bf1 578
0fef449b
RS
579=item *
580
581The C<x> repetition operator is now folded to a single constant at compile
582time if called in scalar context with constant operands and no parentheses
583around the left operand.
584
e5ba1bf1
FC
585=back
586
587=head1 Modules and Pragmata
588
589XXX All changes to installed files in F<cpan/>, F<dist/>, F<ext/> and F<lib/>
590go here. If Module::CoreList is updated, generate an initial draft of the
591following sections using F<Porting/corelist-perldelta.pl>, which prints stub
592entries to STDOUT. Results can be pasted in place of the '=head2' entries
593below. A paragraph summary for important changes should then be added by hand.
594In an ideal world, dual-life modules would have a F<Changes> file that could be
595cribbed.
596
597[ Within each section, list entries as a =item entry ]
598
599=head2 New Modules and Pragmata
600
601=over 4
602
603=item *
604
605XXX
606
607=back
608
609=head2 Updated Modules and Pragmata
610
611=over 4
612
613=item *
614
615L<XXX> has been upgraded from version A.xx to B.yy.
616
617=back
618
619=head2 Removed Modules and Pragmata
620
0bba4573 621=over
e5ba1bf1
FC
622
623=item *
624
0bba4573
RS
625L<Version::Requirements> has been removed from the core distribution. It is
626available under a different name: L<CPAN::Meta::Requirements>.
e5ba1bf1
FC
627
628=back
629
630=head1 Documentation
631
632XXX Changes to files in F<pod/> go here. Consider grouping entries by
633file and be sure to link to the appropriate page, e.g. L<perlfunc>.
634
635=head2 New Documentation
636
637XXX Changes which create B<new> files in F<pod/> go here.
638
639=head3 L<XXX>
640
641XXX Description of the purpose of the new file here
642
643=head2 Changes to Existing Documentation
644
0bba4573 645=head3 L<perldata>
e5ba1bf1 646
0bba4573
RS
647=over 4
648
649=item *
650
651Now explicitly documents the behaviour of hash initializer lists that
652contain duplicate keys.
653
654=back
655
656=head3 L<perldiag>
657
658=over 4
659
660=item *
661
662The explanation of symbolic references being prevented by "strict refs"
663now doesn't assume that the reader knows what symbolic references are.
664
665=back
666
667=head3 L<perlfunc>
e5ba1bf1
FC
668
669=over 4
670
671=item *
672
0bba4573 673The return value of C<pipe> is now documented.
e5ba1bf1 674
37133b20
RS
675=item *
676
677Clarified documentation of C<our>.
678
e5ba1bf1
FC
679=back
680
0fef449b
RS
681=head3 L<perlfaq>
682
683=over 4
684
685=item *
686
687L<perlfaq> has been synchronized with version 5.0150040 from CPAN.
688
689=back
690
691=head3 L<perlcheat>
692
693=over 4
694
695=item *
696
697L<perlcheat> has been reorganized, and a few new sections were added.
698
699=back
700
94b31d3f
RS
701=head3 L<perlop>
702
703=over 4
704
705=item *
706
707Loop control verbs (C<dump>, C<goto>, C<next>, C<last> and C<redo>) have always
708had the same precedence as assignment operators, but this was not documented
709until now.
710
711=back
712
0bba4573 713=head3 Diagnostics
e5ba1bf1
FC
714
715The following additions or changes have been made to diagnostic output,
716including warnings and fatal error messages. For the complete list of
717diagnostic messages, see L<perldiag>.
718
719XXX New or changed warnings emitted by the core's C<C> code go here. Also
720include any changes in L<perldiag> that reconcile it to the C<C> code.
721
722=head2 New Diagnostics
723
724XXX Newly added diagnostic messages go under here, separated into New Errors
725and New Warnings
726
727=head3 New Errors
728
729=over 4
730
731=item *
732
94b31d3f
RS
733L<Unterminated delimiter for here document|perldiag/"Unterminated delimiter for here document">
734
735This message now occurs when a here document label has an initial quotation
736mark but the final quotation mark is missing.
737
738This replaces a bogus and misleading error message about not finding the label
739itself [perl #114104].
740
741=item *
742
743L<panic: child pseudo-process was never scheduled|perldiag/"panic: child pseudo-process was never scheduled">
744
745This error is thrown when a child pseudo-process in the ithreads implementation
746on Windows was not scheduled within the time period allowed and therefore was
747not able to initialize properly [perl #88840].
748
749=item *
750
37133b20
RS
751L<Group name must start with a non-digit word character in regex; marked by <-- HERE in mE<sol>%sE<sol>|perldiag/"Group name must start with a non-digit word character in regex; marked by <-- HERE in m/%s/">
752
753This error has been added for C<(?&0)>, which is invalid. It used to
754produce an incomprehensible error message [perl #101666].
755
756=item *
757
758L<Can't use an undefined value as a subroutine reference|perldiag/"Can't use an undefined value as %s reference">
759
760Calling an undefined value as a subroutine now produces this error message.
761It used to, but was accidentally disabled, first in Perl 5.004 for
762non-magical variables, and then in Perl 5.14 for magical (e.g., tied)
763variables. It has now been restored. In the mean time, undef was treated
764as an empty string [perl #113576].
e5ba1bf1
FC
765
766=back
767
768=head3 New Warnings
769
770=over 4
771
772=item *
773
00785cb7
RS
774L<Experimental "%s" subs not enabled|perldiag/"Experimental "%s" subs not enabled">
775
776(F) To use lexical subs, you must first enable them:
777
778 no warnings 'experimental:lexical_subs';
779 use feature 'lexical_subs';
780 my sub foo { ... }
781
782=item *
783
784L<Subroutine "&%s" is not available|perldiag/"Subroutine "&%s" is not available">
785
786(W closure) During compilation, an inner named subroutine or eval is
787attempting to capture an outer lexical subroutine that is not currently
788available. This can happen for one of two reasons. First, the lexical
789subroutine may be declared in an outer anonymous subroutine that has not
790yet been created. (Remember that named subs are created at compile time,
791while anonymous subs are created at run-time.) For example,
792
793 sub { my sub a {...} sub f { \&a } }
794
795At the time that f is created, it can't capture the current the "a" sub,
796since the anonymous subroutine hasn't been created yet. Conversely, the
797following won't give a warning since the anonymous subroutine has by now
798been created and is live:
799
800 sub { my sub a {...} eval 'sub f { \&a }' }->();
801
802The second situation is caused by an eval accessing a variable that has
803gone out of scope, for example,
804
805 sub f {
806 my sub a {...}
807 sub { eval '\&a' }
808 }
809 f()->();
810
811Here, when the '\&a' in the eval is being compiled, f() is not currently
812being executed, so its &a is not available for capture.
813
814=item *
815
816L<"%s" subroutine &%s masks earlier declaration in same %s|perldiag/"%s" subroutine &%s masks earlier declaration in same %s>
817
818(W misc) A "my" or "state" subroutine has been redeclared in the
819current scope or statement, effectively eliminating all access to
820the previous instance. This is almost always a typographical error.
821Note that the earlier subroutine will still exist until the end of
822the scope or until all closure references to it are destroyed.
823
824=item *
825
826L<The %s feature is experimental|perldiag/"The %s feature is experimental">
827
828(S experimental) This warning is emitted if you enable an experimental
829feature via C<use feature>. Simply suppress the warning if you want
830to use the feature, but know that in doing so you are taking the risk
831of using an experimental feature which may change or be removed in a
832future Perl version:
833
834 no warnings "experimental:lexical_subs";
835 use feature "lexical_subs";
836
837=item *
838
839L<sleep(%u) too large|perldiag/"sleep(%u) too large">
840
841(W overflow) You called C<sleep> with a number that was larger than it can
842reliably handle and C<sleep> probably slept for less time than requested.
843
844=item *
845
94b31d3f
RS
846L<Wide character in setenv|perldiag/"Wide character in %s">
847
848Attempts to put wide characters into environment variables via C<%ENV> now
849provoke this warning.
850
851=item *
852
37133b20
RS
853"L<Invalid negative number (%s) in chr|perldiag/"Invalid negative number (%s) in chr">"
854
855C<chr()> now warns when passed a negative value [perl #83048].
856
857=item *
858
859"L<Integer overflow in srand|perldiag/"Integer overflow in srand">"
860
861C<srand()> now warns when passed a value that doesn't fit in a C<UV> (since the
862value will be truncated rather than overflowing) [perl #40605].
863
864=item *
865
866"L<-i used with no filenames on the command line, reading from STDIN|perldiag/"-i used with no filenames on the command line, reading from STDIN">"
867
868Running perl with the C<-i> flag now warns if no input files are provided on
869the command line [perl #113410].
e5ba1bf1
FC
870
871=back
872
873=head2 Changes to Existing Diagnostics
874
e5ba1bf1
FC
875=over 4
876
877=item *
878
d268df4d
RS
879L<Constant(%s): Call to &{$^H{%s}} did not return a defined value|perldiag/Constant(%s): Call to &{$^H{%s}} did not return a defined value>
880
881Constant overloading that returns C<undef> results in this error message.
882For numeric constants, it used to say "Constant(undef)". "undef" has been
883replaced with the number itself.
884
885=item *
886
f7b06e7f
RS
887The error produced when a module cannot be loaded now includes a hint that
888the module may need to be installed: "Can't locate hopping.pm in @INC (you
889may need to install the hopping module) (@INC contains: ...)"
890
891=item *
892
00785cb7
RS
893L<vector argument not supported with alpha versions|perldiag/vector argument not supported with alpha versions>
894
895This warning was not suppressable, even with C<no warnings>. Now it is
896suppressible, and has been moved from the "internal" category to the
897"printf" category.
898
899=item *
900
901C<< Can't do {n,m} with n > m in regex; marked by <-- HERE in m/%s/ >>
902
903This fatal error has been turned into a warning that reads:
904
905L<< Quantifier {n,m} with n > m can't match in regex | perldiag/Quantifier {n,m} with n > m can't match in regex >>
906
907(W regexp) Minima should be less than or equal to maxima. If you really want
908your regexp to match something 0 times, just put {0}.
909
910=item *
911
0fef449b
RS
912The "Runaway prototype" warning that occurs in bizarre cases has been
913removed as being unhelpful and inconsistent.
914
915=item *
916
917The "Not a format reference" error has been removed, as the only case in
918which it could be triggered was a bug.
919
920=item *
921
922The "Unable to create sub named %s" error has been removed for the same
923reason.
e5ba1bf1 924
37133b20
RS
925=item *
926
927The 'Can't use "my %s" in sort comparison' error has been downgraded to a
928warning, '"my %s" used in sort comparison' (with 'state' instead of 'my'
929for state variables). In addition, the heuristics for guessing whether
930lexical $a or $b has been misused have been improved to generate fewer
931false positives. Lexical $a and $b are no longer disallowed if they are
932outside the sort block. Also, a named unary or list operator inside the
933sort block no longer causes the $a or $b to be ignored [perl #86136].
934
e5ba1bf1
FC
935=back
936
937=head1 Utility Changes
938
f7b06e7f 939=head3 L<h2xs>
e5ba1bf1
FC
940
941=over 4
942
943=item *
944
f7b06e7f 945F<h2xs> no longer produces invalid code for empty defines. [perl #20636]
e5ba1bf1
FC
946
947=back
948
949=head1 Configuration and Compilation
950
951XXX Changes to F<Configure>, F<installperl>, F<installman>, and analogous tools
952go here. Any other changes to the Perl build process should be listed here.
953However, any platform-specific changes should be listed in the
954L</Platform Support> section, instead.
955
956[ List changes as a =item entry ].
957
958=over 4
959
960=item *
961
00785cb7
RS
962F<Configure> will now correctly detect C<isblank()> when compiling with a C++
963compiler.
964
965=item *
966
94b31d3f
RS
967The pager detection in F<Configure> has been improved to allow responses which
968specify options after the program name, e.g. B</usr/bin/less -R>, if the user
969accepts the default value. This helps B<perldoc> when handling ANSI escapes
970[perl #72156].
e5ba1bf1
FC
971
972=back
973
974=head1 Testing
975
976XXX Any significant changes to the testing of a freshly built perl should be
977listed here. Changes which create B<new> files in F<t/> go here as do any
978large changes to the testing harness (e.g. when parallel testing was added).
979Changes to existing files in F<t/> aren't worth summarizing, although the bugs
980that they represent may be covered elsewhere.
981
982[ List each test improvement as a =item entry ]
983
984=over 4
985
986=item *
987
0bba4573
RS
988The test suite now has a section for tests that require very large amounts
989of memory. These tests won't run by default; they can be enabled by
990setting the C<PERL_TEST_MEMORY> environment variable to the number of
991gibibytes of memory that may be safely used.
e5ba1bf1
FC
992
993=back
994
995=head1 Platform Support
996
997XXX Any changes to platform support should be listed in the sections below.
998
999[ Within the sections, list each platform as a =item entry with specific
1000changes as paragraphs below it. ]
1001
1002=head2 New Platforms
1003
1004XXX List any platforms that this version of perl compiles on, that previous
1005versions did not. These will either be enabled by new files in the F<hints/>
1006directories, or new subdirectories and F<README> files at the top level of the
1007source tree.
1008
1009=over 4
1010
1011=item XXX-some-platform
1012
1013XXX
1014
1015=back
1016
1017=head2 Discontinued Platforms
1018
e5ba1bf1
FC
1019=over 4
1020
94b31d3f 1021=item UTS Global
e5ba1bf1 1022
94b31d3f
RS
1023Support code relating to UTS global has been removed. UTS was a mainframe
1024version of System V created by Amdahl, subsequently sold to UTS Global. The
1025port has not been touched since before Perl 5.8.0, and UTS Global is now
1026defunct.
e5ba1bf1 1027
00785cb7
RS
1028=item VM/ESA
1029
1030Support for VM/ESA has been removed. The port was tested on 2.3.0, which
1031IBM ended service on in March 2002. 2.4.0 ended service in June 2003, and
1032was superseded by Z/VM. The current version of Z/VM is V6.2.0, and scheduled
1033for end of service on 2015/04/30.
1034
f7b06e7f
RS
1035=item MPE/IX
1036
1037Support for MPE/IX has been removed.
1038
7e7c78a1
RS
1039=item EPOC
1040
1041Support code relating to EPOC has been removed. EPOC was a family of
1042operating systems developed by Psion for mobile devices. It was the
1043predecessor of Symbian. The port was last updated in April 2002.
1044
e5ba1bf1
FC
1045=back
1046
1047=head2 Platform-Specific Notes
1048
1049XXX List any changes for specific platforms. This could include configuration
1050and compilation changes or changes in portability/compatibility. However,
1051changes within modules for platforms should generally be listed in the
1052L</Modules and Pragmata> section.
1053
1054=over 4
1055
0bba4573 1056=item clang++
e5ba1bf1 1057
0bba4573
RS
1058There is now a workaround for a compiler bug that prevented compiling
1059with clang++ since Perl 5.15.7 [perl #112786].
1060
1061=item C++
1062
1063When compiling the Perl core as C++ (which is only semi-supported), the
1064mathom functions are now compiled as C<extern "C">, to ensure proper
1065binary compatibility. (However, binary compatibility isn't generally
1066guaranteed anyway in the situations where this would matter.)
1067
7e7c78a1
RS
1068=item VMS
1069
1070Where possible, the case of filenames and command-line arguments is now
1071preserved by enabling the CRTL features C<DECC$EFS_CASE_PRESERVE> and
1072C<DECC$ARGV_PARSE_STYLE> at start-up time. The latter only takes effect
1073when extended parse is enabled in the process from which Perl is run.
1074
1075=item WinCE
1076
1077Building on WinCE is now possible once again, although more work is required
1078to fully restore a clean build.
1079
00785cb7
RS
1080=item Win32
1081
1082Fixed a problem where perl could crash while cleaning up threads (including the
1083main thread) in threaded debugging builds on Win32 and possibly other platforms
1084[perl #114496].
1085
1086A rare race condition that would lead to L<sleep|perlfunc/sleep> taking more
1087time than requested, and possibly even hanging, has been fixed [perl #33096].
1088
f7b06e7f
RS
1089=item Win32
1090
1091The option to build without USE_SOCKETS_AS_HANDLES has been removed.
1092
00785cb7
RS
1093=item Solaris
1094
1095In Configure, avoid running sed commands with flags not supported on Solaris.
1096
1097=item Darwin
1098
1099Stop hardcoding an alignment on 8 byte boundaries to fix builds using
1100-Dusemorebits.
1101
1102=item VMS
1103
1104Fix linking on builds configured with -Dusemymalloc=y.
1105
0bba4573
RS
1106=item VMS
1107
1108It should now be possible to compile Perl as C++ on VMS.
e5ba1bf1 1109
0fef449b
RS
1110=item Win32
1111
1112C<link> on Win32 now attempts to set C<$!> to more appropriate values
1113based on the Win32 API error code. [perl #112272]
1114
1115Perl no longer mangles the environment block, e.g. when launching a new
1116sub-process, when the environment contains non-ASCII characters. Known
1117problems still remain, however, when the environment contains characters
1118outside of the current ANSI codepage (e.g. see the item about Unicode in
1119C<%ENV> in L<http://perl5.git.perl.org/perl.git/blob/HEAD:/Porting/todo.pod>).
1120[perl #113536]
1121
37133b20
RS
1122=item Win32
1123
1124Building perl with some Windows compilers used to fail due to a problem
1125with miniperl's C<glob> operator (which uses the C<perlglob> program)
1126deleting the PATH environment variable [perl #113798].
1127
94b31d3f
RS
1128=item Win32
1129
1130A new makefile option, USE_64_BIT_INT, has been added to the Windows makefiles.
1131Set this to "define" when building a 32-bit perl if you want it to use 64-bit
1132integers.
1133
1134Machine code size reductions, already made to the DLLs of XS modules in Perl
11355.17.2, have now been extended to the perl DLL itself.
1136
1137Building with VC++ 6.0 was inadvertently broken in Perl 5.17.2 but has now been
1138fixed again.
1139
0fef449b
RS
1140=item VMS
1141
1142All C header files from the top-level directory of the distribution are now
1143installed on VMS, providing consistency with a long-standing practice on other
1144platforms. Previously only a subset were installed, which broke non-core
1145extension builds for extensions that depended on the missing include files.
1146
37133b20
RS
1147=item VMS
1148
1149Quotes are now removed from the command verb (but not the parameters) for
1150commands spawned via C<system>, backticks, or a piped C<open>. Previously,
1151quotes on the verb were passed through to DCL, which would fail to recognize
1152the command. Also, if the verb is actually a path to an image or command
1153procedure on an ODS-5 volume, quoting it now allows the path to contain spaces.
1154
94b31d3f
RS
1155=item VMS
1156
1157The B<a2p> build has been fixed for the HP C++ compiler on OpenVMS.
1158
37133b20
RS
1159=item AIX
1160
1161Configure now always adds C<-qlanglvl=extc99> to the CC flags on AIX when
1162using xlC. This will make it easier to compile a number of XS-based modules
1163that assume C99 [perl #113778].
1164
e5ba1bf1
FC
1165=back
1166
1167=head1 Internal Changes
1168
0bba4573 1169=over
e5ba1bf1 1170
0bba4573 1171=item *
e5ba1bf1 1172
d268df4d
RS
1173SvUPGRADE() is no longer an expression. Originally this macro (and its
1174underlying function, sv_upgrade()) were documented as boolean, although
1175in reality they always croaked on error and never returned false. In 2005
1176the documentation was updated to specify a void return value, but
1177SvUPGRADE() was left always returning 1 for backwards compatibility. This
1178has now been removed, and SvUPGRADE() is now a statement with no return
1179value.
1180
1181So this is now a syntax error:
1182
1183 if (!SvUPGRADE(sv)) { croak(...); }
1184
1185If you have code like that, simply replace it with
1186
1187 SvUPGRADE(sv);
1188
1189or to to avoid compiler warnings with older perls, possibly
1190
1191 (void)SvUPGRADE(sv);
1192
1193=item *
1194
1195Perl has a new copy-on-write mechanism that allows any SvPOK scalar to be
1196upgraded to a copy-on-write scalar. A reference count on the string buffer
1197is stored in the string buffer itself.
1198
1199This breaks a few XS modules by allowing copy-on-write scalars to go
1200through code paths that never encountered them before.
1201
1202This behaviour can still be disabled by running F<Configure> with
1203B<-Accflags=-DPERL_NO_COW>. This option will probably be removed in Perl
12045.20.
1205
1206=item *
1207
1208Copy-on-write no longer uses the SvFAKE and SvREADONLY flags. Hence,
1209SvREADONLY indicates a true read-only SV.
1210
1211Use the SvIsCOW macro (as before) to identify a copy-on-write scalar.
1212
1213=item *
1214
1215C<PL_sawampersand> is now a constant. The switch this variable provided
1216(to enable/disable the pre-match copy depending on whether C<$&> had been
1217seen) has been removed and replaced with copy-on-write, eliminating a few
1218bugs.
1219
1220The previous behaviour can still be enabled by running F<Configure> with
1221B<-Accflags=-DPERL_SAWAMPERSAND>.
1222
1223=item *
1224
1225PL_glob_index is gone.
1226
1227=item *
1228
7e7c78a1
RS
1229The private Perl_croak_no_modify has had its context parameter removed. It is
1230now has a void prototype. Users of the public API croak_no_modify remain
1231unaffected.
1232
1233=item *
1234
1235Copy-on-write (shared hash key) scalars are no longer marked read-only.
1236C<SvREADONLY> returns false on such an SV, but C<SvIsCOW> still returns
1237true.
1238
1239=item *
1240
1241A new op type, C<OP_PADRANGE> has been introduced. The perl peephole
1242optimiser will, where possible, substitute a single padrange op for a
1243pushmark followed by one or more pad ops, and possibly also skipping list
1244and nextstate ops. In addition, the op can carry out the tasks associated
1245with the RHS of a my(...) = @_ assignment, so those ops may be optimised
1246away too.
1247
1248=item *
1249
f7b06e7f
RS
1250Case-insensitive matching inside a [bracketed] character class with a
1251multi-character fold, no longer excludes one of the possibilities in the
1252circumstances that it used to. [perl #89774].
1253
1254=item *
1255
1256C<PL_formfeed> has been removed.
1257
1258=item *
1259
1260The regular expression engine no longer reads one byte past the end of the
1261target string. While for all internally well-formed scalars this should
1262never have been a problem, this change facilitates clever tricks with
1263string buffers in CPAN modules. [perl #73542]
1264
1265=item *
1266
1267Inside a BEGIN block, C<PL_compcv> now points to the currently-compiling
1268subroutine, rather than the BEGIN block itself.
1269
1270=item *
1271
1272C<mg_length> has been deprecated.
1273
1274=item *
1275
1276C<sv_len> now always returns a byte count and C<sv_len_utf8> a character
1277count. Previously, C<sv_len> and C<sv_len_utf8> were both buggy and would
1278sometimes returns bytes and sometimes characters. C<sv_len_utf8> no longer
1279assumes that its argument is in UTF8. Neither of these creates UTF8 caches
1280for tied or overloaded values or for non-PVs any more.
1281
1282=item *
1283
1284C<sv_mortalcopy> now copies string buffers of shared hash key scalars when
1285called from XS modules [perl #79824].
1286
1287=item *
1288
1289C<RXf_SPLIT> and C<RXf_SKIPWHITE> are no longer used. They are now
1290#defined as 0.
1291
1292=item *
1293
1294The new C<RXf_MODIFIES_VARS> flag can be set by custom regular expression
1295engines to indicate that the execution of the regular expression may cause
1296variables to be modified. This lets C<s///> know to skip certain
1297optimisations. Perl's own regular expression engine sets this flag for the
1298special backtracking verbs that set $REGMARK and $REGERROR.
1299
1300=item *
1301
00785cb7
RS
1302The APIs for accessing lexical pads have changed considerably.
1303
1304C<PADLIST>s are now longer C<AV>s, but their own type instead. C<PADLIST>s now
1305contain a C<PAD> and a C<PADNAMELIST> of C<PADNAME>s, rather than C<AV>s for the
1306pad and the list of pad names. C<PAD>s, C<PADNAMELIST>s, and C<PADNAME>s are to
1307be accessed as such through the newly added pad API instead of the plain C<AV>
1308and C<SV> APIs. See L<perlapi> for details.
1309
1310=item *
1311
1312In the regex API, the numbered capture callbacks are passed an index
1313indicating what match variable is being accessed. There are special
1314index values for the C<$`, $&, $&> variables. Previously the same three
1315values were used to retrieve C<${^PREMATCH}, ${^MATCH}, ${^POSTMATCH}>
1316too, but these have now been assigned three separate values. See
1317L<perlreapi/Numbered capture callbacks>.
1318
1319=item *
1320
1321C<PL_sawampersand> was previously a boolean indicating that any of
1322C<$`, $&, $&> had been seen; it now contains three one-bit flags
1323indicating the presence of each of the variables individually.
1324
00785cb7
RS
1325=item *
1326
0bba4573
RS
1327The C<CV *> typemap entry now supports C<&{}> overloading and typeglobs,
1328just like C<&{...}> [perl #96872].
e5ba1bf1
FC
1329
1330=item *
1331
0bba4573
RS
1332The C<SVf_AMAGIC> flag to indicate overloading is now on the stash, not the
1333object. It is now set automatically whenever a method or @ISA changes, so
1334its meaning has changed, too. It now means "potentially overloaded". When
1335the overload table is calculated, the flag is automatically turned off if
1336there is no overloading, so there should be no noticeable slowdown.
1337
1338The staleness of the overload tables is now checked when overload methods
1339are invoked, rather than during C<bless>.
1340
1341"A" magic is gone. The changes to the handling of the C<SVf_AMAGIC> flag
1342eliminate the need for it.
1343
1344C<PL_amagic_generation> has been removed as no longer necessary. For XS
1345modules, it is now a macro alias to C<PL_na>.
1346
1347The fallback overload setting is now stored in a stash entry separate from
1348overloadedness itself.
1349
1350=item *
1351
1352The character-processing code has been cleaned up in places. The changes
1353should be operationally invisible.
e5ba1bf1 1354
0fef449b
RS
1355=item *
1356
1357The C<study> function was made a no-op in 5.16. It was simply disabled via
1358a C<return> statement; the code was left in place. Now the code supporting
1359what C<study> used to do has been removed.
1360
1361=item *
1362
1363Under threaded perls, there is no longer a separate PV allocated for every
1364COP to store its package name (C<< cop->stashpv >>). Instead, there is an
1365offset (C<< cop->stashoff >>) into the new C<PL_stashpad> array, which
1366holds stash pointers.
1367
1368=item *
1369
1370In the pluggable regex API, the C<regexp_engine> struct has acquired a new
1371field C<op_comp>, which is currently just for perl's internal use, and
1372should be initialised to NULL by other regex plugin modules.
1373
1374=item *
1375
1376A new function C<alloccoptash> has been added to the API, but is considered
1377experimental. See L<perlapi>.
1378
37133b20
RS
1379=item *
1380
1381Perl used to implement get magic in a way that would sometimes hide bugs in
1382code could call mg_get() too many times on magical values. This hiding of
1383errors no longer occurs, so long-standing bugs may become visible now. If
1384you see magic-related errors in XS code, check to make sure it, together
1385with the Perl API functions it uses, calls mg_get() only once on SvGMAGICAL()
1386values.
1387
1388=item *
1389
1390OP allocation for CVs now uses a slab allocator. This simplifies
1391memory management for OPs allocated to a CV, so cleaning up after a
1392compilation error is simpler and safer [perl #111462][perl #112312].
1393
1394=item *
1395
1396PERL_DEBUG_READONLY_OPS has been rewritten to work with the new slab
1397allocator, allowing it to catch more violations than before.
1398
1399=item *
1400
1401The old slab allocator for ops, which was only enabled for PERL_IMPLICIT_SYS
1402and PERL_DEBUG_READONLY_OPS, has been retired.
1403
e5ba1bf1
FC
1404=back
1405
1406=head1 Selected Bug Fixes
1407
94b31d3f
RS
1408=over 4
1409
1410=item *
e5ba1bf1 1411
d268df4d
RS
1412C<sort {undef} ...> under fatal warnings no longer crashes. It started
1413crashing in Perl 5.16.
1414
1415=item *
1416
1417Stashes blessed into each other
1418(C<bless \%Foo::, 'Bar'; bless \%Bar::, 'Foo'>) no longer result in double
1419frees. This bug started happening in Perl 5.16.
1420
1421=item *
1422
1423Numerous memory leaks have been fixed, mostly involving fatal warnings and
1424syntax errors.
1425
1426=item *
1427
1428Lexical constants (C<my sub answer () { 42 }>) no longer cause double
1429frees.
1430
1431=item *
1432
1433Constant subroutine redefinition warns by default, but lexical constants
1434were accidentally exempt from default warnings. This has been corrected.
1435
1436=item *
1437
1438Some failed regular expression matches such as C<'f' =~ /../g> were not
1439resetting C<pos>. Also, "match-once" patterns (C<m?...?g>) failed to reset
1440it, too, when invoked a second time [perl #23180].
1441
1442=item *
1443
1444Accessing C<$&> after a pattern match now works if it had not been seen
1445before the match. I.e., this applies to C<${'&'}> (under C<no strict>) and
1446C<eval '$&'>. The same applies to C<$'> and C<$`> [perl #4289].
1447
1448=item *
1449
1450Several bugs involving C<local *ISA> and C<local *Foo::> causing stale
1451MRO caches have been fixed.
1452
1453=item *
1454
1455Defining a subroutine when its typeglob has been aliased no longer results
1456in stale method caches. This bug was introduced in Perl 5.10.
1457
1458=item *
1459
1460Localising a typeglob containing a subroutine when the typeglob's package
1461has been deleted from its parent stash no longer produces an error. This
1462bug was introduced in Perl 5.14.
1463
1464=item *
1465
1466Under some circumstances, C<local *method=...> would fail to reset method
1467caches upon scope exit.
1468
1469=item *
1470
1471C</[.foo.]/> is no longer an error, but produces a warning (as before) and
1472is treated as C</[.fo]/> [perl #115818].
1473
1474=item *
1475
1476C<goto $tied_var> now calls FETCH before deciding what type of goto
1477(subroutine or label) this is.
1478
1479=item *
1480
1481Renaming packages through glob assignment
1482(C<*Foo:: = *Bar::; *Bar:: = *Baz::>) in combination with C<m?...?> and
1483C<reset> no longer makes threaded builds crash.
1484
1485=item *
1486
1487An earlier release in the 5.17.x series could crash if user code prevented
1488_charnames from loading via C<$INC{'_charnames.pm'}++>.
1489
1490=item *
1491
1492A number of bugs related to assigning a list to hash have been fixed. Many of
1493these involve lists with repeated keys like C<(1, 1, 1, 1)>.
1494
1495=over 4
1496
1497=item *
1498
1499The expression C<scalar(%h = (1, 1, 1, 1))> now returns C<4>, not C<2>.
1500
1501=item *
1502
1503The return value of C<%h = (1, 1, 1)> in list context was wrong. Previously
1504this would return C<(1, undef, 1)>, now it returns C<(1, undef)>.
1505
1506=item *
1507
1508Perl now issues the same warning on C<($s, %h) = (1, {})> as it does for
1509C<(%h) = ({})>, "Reference found where even-sized list expected".
1510
1511=item *
1512
1513A number of additional edge cases in list assignment to hashes were
1514corrected. For more details see commit 23b7025ebc.
1515
1516=back
1517
1518=item *
1519
f7b06e7f
RS
1520A bug, case-insensitive regex with UTF8-flagged strings, introduced
1521earlier in the 5.17 series has been fixed. [perl #114982]
1522
1523=item *
1524
1525Attributes applied to lexical variables no longer leak memory.
1526[perl #114764]
1527
1528=item *
1529
1530C<dump>, C<goto>, C<last>, C<next>, C<redo> or C<require> followed by a
1531bareword (or version) and then an infix operator is no longer a syntax
1532error. It used to be for those infix operators (like C<+>) that have a
1533different meaning where a term is expected. [perl #105924]
1534
1535=item *
1536
1537C<require a::b . 1> and C<require a::b + 1> no longer produce erroneous
1538ambiguity warnings. [perl #107002]
1539
1540=item *
1541
1542Class method calls are now allowed on any string, and not just strings
1543beginning with an alphanumeric character. [perl #105922]
1544
1545=item *
1546
1547An empty pattern created with C<qr//> used in C<m///> no longer triggers
1548the "empty pattern reuses last pattern" behaviour. [perl #96230]
1549
1550=item *
1551
1552Tying a hash during iteration no longer results in a memory leak.
1553
1554=item *
1555
1556Freeing a tied hash during iteration no longer results in a memory leak.
1557
1558=item *
1559
1560List assignment to a tied array or hash that dies on STORE no longer
1561results in a memory leak.
1562
1563=item *
1564
1565If the hint hash (C<%^H>) is tied, compile-time scope entry (which copies
1566the hint hash) no longer leaks memory if FETCH dies. [perl #107000]
1567
1568=item *
1569
1570Constant folding no longer inappropriately triggers the special
1571C<split " "> behaviour. [perl #94490]
1572
1573=item *
1574
1575C<defined scalar(@array)>, C<defined do { &foo }>, and similar constructs
1576now treat the argument to C<defined> as a simple scalar. [perl #97466]
1577
1578=item *
1579
1580Running a custom debugging that defines no C<*DB::DB> glob or provides a
1581subroutine stub for C<&DB::DB> no longer results in a crash, but an error
1582instead. [perl #114990]
1583
1584=item *
1585
1586C<reset ""> now matches its documentation. C<reset> only resets C<m?...?>
1587patterns when called with no argument. An empty string for an argument now
1588does nothing. (It used to be treated as no argument.) [perl #97958]
1589
1590=item *
1591
1592C<printf> with an argument returning an empty list no longer reads past the
1593end of the stack, resulting in erratic behaviour. [perl #77094]
1594
1595=item *
1596
1597C<--subname> no longer produces erroneous ambiguity warnings.
1598[perl #77240]
1599
1600=item *
1601
1602C<v10> is now allowed as a label or package name. This was inadvertently
1603broken when v-strings were added in Perl 5.6. [perl #56880]
1604
1605=item *
1606
1607A regression introduced in 5.17.2 has been fixed, which made C</[\@\\]||/>
1608result in a "panic" error. [perl #115050]
1609
1610=item *
1611
1612C<length>, C<pos>, C<substr> and C<sprintf> could be confused by ties,
1613overloading, references and typeglobs if the stringification of such
1614changed the internal representation to or from UTF8. [perl #114410]
1615
1616=item *
1617
1618utf8::encode now calls FETCH and STORE on tied variables. utf8::decode now
1619calls STORE (it was already calling FETCH).
1620
1621=item *
1622
1623C<$tied =~ s/$non_utf8/$utf8/> no longer loops infinitely if the tied
1624variable returns a Latin-1 string, shared hash key scalar, or reference or
1625typeglob that stringifies as ASCII or Latin-1. This is a regression from
16265.12.x.
1627
1628=item *
1629
1630C<s///> without /e is now better at detecting when it needs to forego
1631certain optimisations, fixing some buggy cases:
1632
1633=over
1634
1635=item *
1636
1637Match variables in certain constructs (C<&&>, C<||>, C<..> and others) in
1638the replacement part; e.g., C<s/(.)/$l{$a||$1}/g>. [perl #26986]
1639
1640=item *
1641
1642Aliases to match variables in the replacement.
1643
1644=item *
1645
1646$REGERROR or $REGMARK in the replacement. [perl #49190]
1647
1648=item *
1649
1650An empty pattern (C<s//$foo/>) that causes the last-successful pattern to
1651be used, when that pattern contains code blocks that modify the variables
1652in the replacement.
1653
1654=back
1655
1656=item *
1657
1658The taintedness of the replacement string no longer affects the taintedness
1659of the return value of C<s///e>.
1660
1661=item *
1662
1663The C<$|> autoflush variable is created on-the-fly when needed. If this
1664happened (e.g., if it was mentioned in a module or eval) when the
1665currently-selected filehandle was a typeglob with an empty IO slot, it used
1666to crash. [perl #115206]
1667
1668=item *
1669
1670Line numbers at the end of a string eval are no longer off by one.
1671[perl #114658]
1672
1673=item *
1674
1675@INC filters (subroutines returned by subroutines in @INC) that set $_ to a
1676copy-on-write scalar no longer cause the parser to modify that string
1677buffer in place.
1678
1679=item *
1680
1681C<length($object)> no longer returns the undefined value if the object has
1682string overloading that returns undef. [perl #115260]
1683
1684=item *
1685
1686The use of C<PL_stashcache>, the stash name lookup cache for method calls, has
1687been restored,
1688
1689Commit da6b625f78f5f133 in August 2011 inadvertently broke the code that looks
1690up values in C<PL_stashcache>. As it's a only cache, quite correctly everything
1691carried on working without it.
1692
1693=item *
1694
00785cb7
RS
1695The error "Can't localize through a reference" had disappeared in 5.16.0
1696when C<local %$ref> appeared on the last line of an lvalue subroutine.
1697This error disappeared for C<\local %$ref> in perl 5.8.1. It has now
1698been restored.
1699
1700=item *
1701
1702The parsing of here-docs has been improved significantly, fixing several
1703parsing bugs and crashes and one memory leak, and correcting wrong
1704subsequent line numbers under certain conditions.
1705
1706=item *
1707
1708Inside an eval, the error message for an unterminated here-doc no longer
1709has a newline in the middle of it [perl #70836].
1710
1711=item *
1712
1713A substitution inside a substitution pattern (C<s/${s|||}//>) no longer
1714confuses the parser.
1715
1716=item *
1717
1718It may be an odd place to allow comments, but C<s//"" # hello/e> has
1719always worked, I<unless> there happens to be a null character before the
1720first #. Now it works even in the presence of nulls.
1721
1722=item *
1723
1724An invalid range in C<tr///> or C<y///> no longer results in a memory leak.
1725
1726=item *
1727
1728String eval no longer treats a semicolon-delimited quote-like operator at
1729the very end (C<eval 'q;;'>) as a syntax error.
1730
1731=item *
1732
1733C<< warn {$_ => 1} + 1 >> is no longer a syntax error. The parser used to
1734get confused with certain list operators followed by an anonymous hash and
1735then an infix operator that shares its form with a unary operator.
1736
1737=item *
1738
1739C<(caller $n)[6]> (which gives the text of the eval) used to return the
1740actual parser buffer. Modifying it could result in crashes. Now it always
1741returns a copy. The string returned no longer has "\n;" tacked on to the
1742end. The returned text also includes here-doc bodies, which used to be
1743omitted.
1744
1745=item *
1746
1747Reset the utf8 position cache when accessing magical variables to avoid the
1748string buffer and the utf8 position cache getting out of sync
1749[perl #114410].
1750
1751=item *
1752
1753Various cases of get magic being called twice for magical utf8 strings have been
1754fixed.
1755
1756=item *
1757
1758This code (when not in the presence of C<$&> etc)
1759
1760 $_ = 'x' x 1_000_000;
1761 1 while /(.)/;
1762
1763used to skip the buffer copy for performance reasons, but suffered from C<$1>
1764etc changing if the original string changed. That's now been fixed.
1765
1766=item *
1767
1768Perl doesn't use PerlIO anymore to report out of memory messages, as PerlIO
1769might attempt to allocate more memory.
1770
1771=item *
1772
1773In a regular expression, if something is quantified with C<{n,m}>
1774where C<S<n E<gt> m>>, it can't possibly match. Previously this was a fatal error,
1775but now is merely a warning (and that something won't match). [perl #82954].
1776
1777=item *
1778
1779It used to be possible for formats defined in subroutines that have
1780subsequently been undefined and redefined to close over variables in the
1781wrong pad (the newly-defined enclosing sub), resulting in crashes or
1782"Bizarre copy" errors.
1783
1784=item *
1785
1786Redefinition of XSUBs at run time could produce warnings with the wrong
1787line number.
1788
1789=item *
1790
1791The %vd sprintf format does not support version objects for alpha versions.
1792It used to output the format itself (%vd) when passed an alpha version, and
1793also emit an "Invalid conversion in printf" warning. It no longer does,
1794but produces the empty string in the output. It also no longer leaks
1795memory in this case.
1796
1797=item *
1798
1799A bug fix in an earlier 5.17.x release caused C<no a a 3> (a syntax error)
1800to result in a bad read or assertion failure, because an op was being freed
1801twice.
1802
1803=item *
1804
1805C<< $obj->SUPER::method >> calls in the main package could fail if the
1806SUPER package had already been accessed by other means.
1807
1808=item *
1809
1810Stash aliasing (C<*foo:: = *bar::>) no longer causes SUPER calls to ignore
1811changes to methods or @ISA or use the wrong package.
1812
1813=item *
1814
1815Method calls on packages whose names end in ::SUPER are no longer treated
1816as SUPER method calls, resulting in failure to find the method.
1817Furthermore, defining subroutines in such packages no longer causes them to
1818be found by SUPER method calls on the containing package [perl #114924].
1819
00785cb7
RS
1820=item *
1821
94b31d3f
RS
1822C<\w> now matches the code points U+200C (ZERO WIDTH NON-JOINER) and U+200D
1823(ZERO WIDTH JOINER). C<\W> no longer matches these. This change is because
1824Unicode corrected their definition of what C<\w> should match.
e5ba1bf1 1825
94b31d3f
RS
1826=item *
1827
1828C<dump LABEL> no longer leaks its label.
1829
1830=item *
1831
1832Constant folding no longer changes the behaviour of functions like C<stat()>
1833and C<truncate()> that can take either filenames or handles.
1834C<stat 1 ? foo : bar> nows treats its argument as a file name (since it is an
1835arbitrary expression), rather than the handle "foo".
1836
1837=item *
1838
1839C<truncate FOO, $len> no longer falls back to treating "FOO" as a file name if
1840the filehandle has been deleted. This was broken in Perl 5.16.0.
1841
1842=item *
1843
1844Subroutine redefinitions after sub-to-glob and glob-to-glob assignments no
1845longer cause double frees or panic messages.
1846
1847=item *
1848
1849C<s///> now turns vstrings into plain strings when performing a substitution,
1850even if the resulting string is the same (C<s/a/a/>).
1851
1852=item *
1853
1854Prototype mismatch warnings no longer erroneously treat constant subs as having
1855no prototype when they actually have "".
1856
1857=item *
1858
1859Constant subroutines and forward declarations no longer prevent prototype
1860mismatch warnings from omitting the sub name.
1861
1862=item *
1863
1864C<undef> on a subroutine now clears call checkers.
1865
1866=item *
1867
1868The C<ref> operator started leaking memory on blessed objects in Perl 5.16.0.
1869This has been fixed [perl #114340].
1870
1871=item *
1872
1873C<use> no longer tries to parse its arguments as a statement, making
1874C<use constant { () };> a syntax error [perl #114222].
1875
1876=item *
1877
1878On debugging builds, "uninitialized" warnings inside formats no longer cause
1879assertion failures.
1880
1881=item *
1882
1883On debugging builds, subroutines nested inside formats no longer cause
1884assertion failures [perl #78550].
1885
1886=item *
1887
1888Formats and C<use> statements are now permitted inside formats.
1889
1890=item *
1891
1892C<print $x> and C<sub { print $x }-E<gt>()> now always produce the same output.
1893It was possible for the latter to refuse to close over $x if the variable was
1894not active; e.g., if it was defined outside a currently-running named
1895subroutine.
1896
1897=item *
1898
1899Similarly, C<print $x> and C<print eval '$x'> now produce the same output.
1900This also allows "my $x if 0" variables to be seen in the debugger [perl
1901#114018].
1902
1903=item *
1904
1905Formats called recursively no longer stomp on their own lexical variables, but
1906each recursive call has its own set of lexicals.
1907
1908=item *
1909
1910Attempting to free an active format or the handle associated with it no longer
1911results in a crash.
1912
1913=item *
1914
1915Format parsing no longer gets confused by braces, semicolons and low-precedence
1916operators. It used to be possible to use braces as format delimiters (instead
1917of C<=> and C<.>), but only sometimes. Semicolons and low-precedence operators
1918in format argument lines no longer confuse the parser into ignoring the line's
1919return value. In format argument lines, braces can now be used for anonymous
1920hashes, instead of being treated always as C<do> blocks.
1921
1922=item *
1923
1924Formats can now be nested inside code blocks in regular expressions and other
1925quoted constructs (C</(?{...})/> and C<qq/${...}/>) [perl #114040].
1926
1927=item *
1928
1929Formats are no longer created after compilation errors.
1930
1931=item *
1932
1933Some format syntax errors started causing crashes in Perl 5.17.2, but have now
1934been fixed.
1935
1936=item *
1937
1938Under debugging builds, the B<-DA> command line option started crashing in Perl
19395.16.0. It has been fixed [perl #114368].
1940
1941=item *
1942
1943Scope::Escape compatibility, which was broken in Perl 5.17.2, has been restored
1944[perl #113872].
1945
1946=item *
1947
1948A potential deadlock scenario involving the premature termination of a pseudo-
1949forked child in a Windows build with ithreads enabled has been fixed. This
1950resolves the common problem of the F<t/op/fork.t> test hanging on Windows [perl
1951#88840].
1952
1953=item *
1954
1955The microperl build, broken since Perl 5.15.7, has now been restored.
1956
1957=item *
1958
1959The code which generates errors from C<require()> could potentially read one or
1960two bytes before the start of the filename for filenames less than three bytes
1961long and ending C</\.p?\z/>. This has now been fixed. Note that it could
1962never have happened with module names given to C<use()> or C<require()> anyway.
1963
1964=item *
1965
1966The handling of pathnames of modules given to C<require()> has been made
1967thread-safe on VMS.
1968
1969=item *
1970
1971The C<re_compile()> API function, the entry point for perl's regex compiler,
1972was accidentally changed in Perl 5.17.1 to operate on the current engine. This
1973has now been restored to its former core-engine-specific state [perl #114302].
1974
1975=item *
1976
1977Perl 5.17.1 introduced a memory leak into the re-use of run-time regexes where
1978the pattern hasn't changed (i.e. C</$unchanging/>). This has now been fixed.
1979
1980=item *
1981
1982A bug in the compilation of a C</(?{})/> expression which affected the TryCatch
1983test suite has been fixed [perl #114242].
1984
1985=item *
1986
1987Formats no longer leak. They started leaking in Perl 5.17.2.
1988
1989=item *
1990
1991Pod can now be nested in code inside a quoted construct outside of a string
1992eval. This used to work only within string evals [perl #114040].
e5ba1bf1
FC
1993
1994=item *
1995
0bba4573
RS
1996C<goto ''> now looks for an empty label, producing the "goto must have
1997label" error message, instead of exiting the program [perl #111794].
e5ba1bf1 1998
0bba4573 1999=item *
e5ba1bf1 2000
0bba4573
RS
2001C<goto "\0"> now dies with "Can't find label" instead of "goto must have
2002label".
e5ba1bf1 2003
0bba4573 2004=item *
e5ba1bf1 2005
0bba4573
RS
2006The C function C<hv_store> used to result in crashes when used on C<%^H>
2007[perl #111000].
e5ba1bf1 2008
0bba4573
RS
2009=item *
2010
2011A call checker attached to a closure prototype via C<cv_set_call_checker>
2012is now copied to closures cloned from it. So C<cv_set_call_checker> now
2013works inside an attribute handler for a closure.
e5ba1bf1
FC
2014
2015=item *
2016
0bba4573
RS
2017Writing to C<$^N> used to have no effect. Now it croaks with "Modification
2018of a read-only value" by default, but that can be overridden by a custom
2019regular expression engine, as with C<$1> [perl #112184].
2020
23dd6e2e
FC
2021=item *
2022
0bba4573
RS
2023C<undef> on a control character glob (C<undef *^H>) no longer emits an
2024erroneous warning about ambiguity [perl #112456].
23dd6e2e 2025
0bba4573
RS
2026=item *
2027
2028For efficiency's sake, many operators and built-in functions return the
2029same scalar each time. Lvalue subroutines and subroutines in the CORE::
2030namespace were allowing this implementation detail to leak through.
2031C<print &CORE::uc("a"), &CORE::uc("b")> used to print "BB". The same thing
2032would happen with an lvalue subroutine returning the return value of C<uc>.
2033Now the value is copied in such cases.
23dd6e2e
FC
2034
2035=item *
2036
0bba4573
RS
2037C<method {}> syntax with an empty block or a block returning an empty list
2038used to crash or use some random value left on the stack as its invocant.
2039Now it produces an error.
b92848b5 2040
0f023b5a
FC
2041=item *
2042
0bba4573 2043C<vec> now works with extremely large offsets (E<gt>2 GB) [perl #111730].
0f023b5a
FC
2044
2045=item *
2046
0bba4573
RS
2047Changes to overload settings now take effect immediately, as do changes to
2048inheritance that affect overloading. They used to take effect only after
2049C<bless>.
2050
2051Objects that were created before a class had any overloading used to remain
2052non-overloaded even if the class gained overloading through C<use overload>
2053or @ISA changes, and even after C<bless>. This has been fixed
2054[perl #112708].
c53e3a75
FC
2055
2056=item *
2057
0bba4573 2058Classes with overloading can now inherit fallback values.
c53e3a75
FC
2059
2060=item *
2061
0bba4573
RS
2062Overloading was not respecting a fallback value of 0 if there were
2063overloaded objects on both sides of an assignment operator like C<+=>
2064[perl #111856].
0f023b5a
FC
2065
2066=item *
2067
0bba4573
RS
2068C<pos> now croaks with hash and array arguments, instead of producing
2069erroneous warnings.
0f023b5a
FC
2070
2071=item *
2072
0bba4573
RS
2073C<while(each %h)> now implies C<while(defined($_ = each %h))>, like
2074C<readline> and C<readdir>.
0f023b5a 2075
0bba4573
RS
2076=item *
2077
2078Subs in the CORE:: namespace no longer crash after C<undef *_> when called
2079with no argument list (C<&CORE::time> with no parentheses).
2080
2081=item *
2082
2083Unicode 6.1 published an incorrect alias for one of the
2084Canonical_Combining_Class property's values (which range between 0 and
2085254). The alias C<CCC133> should have been C<CCC132>. Perl now
2086overrides the data file furnished by Unicode to give the correct value.
2087
2088=item *
2089
2090C<unpack> no longer produces the "'/' must follow a numeric type in unpack"
2091error when it is the data that are at fault [perl #60204].
2092
2093=item *
2094
2095C<join> and C<"@array"> now call FETCH only once on a tied C<$">
2096[perl #8931].
2097
2098=item *
2099
2100Some subroutine calls generated by compiling core ops affected by a
2101C<CORE::GLOBAL> override had op checking performed twice. The checking
2102is always idempotent for pure Perl code, but the double checking can
2103matter when custom call checkers are involved.
2104
2105=item *
2106
2107A race condition used to exist around fork that could cause a signal sent to
2108the parent to be handled by both parent and child. Signals are now blocked
2109briefly around fork to prevent this from happening [perl #82580].
e5ba1bf1 2110
0fef449b
RS
2111=item *
2112
2113The implementation of code blocks in regular expressions, such as C<(?{})>
2114and C<(??{})>, has been heavily reworked to eliminate a whole slew of bugs.
2115The main user-visible changes are:
2116
2117=over 4
2118
2119=item *
2120
2121Code blocks within patterns are now parsed in the same pass as the
2122surrounding code; in particular it is no longer necessary to have balanced
2123braces: this now works:
2124
2125 /(?{ $x='{' })/
2126
2127This means that this error message is longer generated:
2128
2129 Sequence (?{...}) not terminated or not {}-balanced in regex
2130
2131but a new error may be seen:
2132
2133 Sequence (?{...}) not terminated with ')'
2134
2135In addition, literal code blocks within run-time patterns are only
2136compiled once, at perl compile-time:
2137
2138 for my $p (...) {
2139 # this 'FOO' block of code is compiled once,
2140 # at the same time as the surrounding 'for' loop
2141 /$p{(?{FOO;})/;
2142 }
2143
2144=item *
2145
2146Lexical variables are now sane as regards scope, recursion and closure
2147behavior. In particular, C</A(?{B})C/> behaves (from a closure viewpoint)
2148exactly like C</A/ && do { B } && /C/>, while C<qr/A(?{B})C/> is like
2149C<sub {/A/ && do { B } && /C/}>. So this code now works how you might
2150expect, creating three regexes that match 0, 1, and 2:
2151
2152 for my $i (0..2) {
2153 push @r, qr/^(??{$i})$/;
2154 }
2155 "1" =~ $r[1]; # matches
2156
2157=item *
2158
2159The C<use re 'eval'> pragma is now only required for code blocks defined
2160at runtime; in particular in the following, the text of the C<$r> pattern is
2161still interpolated into the new pattern and recompiled, but the individual
2162compiled code-blocks within C<$r> are reused rather than being recompiled,
2163and C<use re 'eval'> isn't needed any more:
2164
2165 my $r = qr/abc(?{....})def/;
2166 /xyz$r/;
2167
2168=item *
2169
2170Flow control operators no longer crash. Each code block runs in a new
2171dynamic scope, so C<next> etc. will not see
2172any enclosing loops. C<return> returns a value
2173from the code block, not from any enclosing subroutine.
2174
2175=item *
2176
2177Perl normally caches the compilation of run-time patterns, and doesn't
2178recompile if the pattern hasn't changed, but this is now disabled if
2179required for the correct behavior of closures. For example:
2180
2181 my $code = '(??{$x})';
2182 for my $x (1..3) {
2183 # recompile to see fresh value of $x each time
2184 $x =~ /$code/;
2185 }
2186
0fef449b
RS
2187=item *
2188
2189The C</msix> and C<(?msix)> etc. flags are now propagated into the return
2190value from C<(??{})>; this now works:
2191
2192 "AB" =~ /a(??{'b'})/i;
2193
2194=item *
2195
2196Warnings and errors will appear to come from the surrounding code (or for
2197run-time code blocks, from an eval) rather than from an C<re_eval>:
2198
2199 use re 'eval'; $c = '(?{ warn "foo" })'; /$c/;
2200 /(?{ warn "foo" })/;
2201
2202formerly gave:
2203
2204 foo at (re_eval 1) line 1.
2205 foo at (re_eval 2) line 1.
2206
2207and now gives:
2208
2209 foo at (eval 1) line 1.
2210 foo at /some/prog line 2.
2211
2212=back
2213
2214=item *
2215
2216Perl now works as well as can be expected on all releases of Unicode so
2217far. In v5.16, it worked on Unicodes 6.0 and 6.1, but there were
2218various bugs for earlier releases; the older the release the more
2219problems.
2220
2221=item *
2222
2223C<vec> no longer produces "uninitialized" warnings in lvalue context
2224[perl #9423].
2225
2226=item *
2227
2228An optimization involving fixed strings in regular expressions could cause
2229a severe performance penalty in edge cases. This has been fixed
2230[perl #76546].
2231
2232=item *
2233
2234In certain cases, including empty subpatterns within a regular expression (such
2235as C<(?:)> or C<(?:|)>) could disable some optimizations. This has been fixed.
2236
2237=item *
2238
2239The "Can't find an opnumber" message that C<prototype> produces when passed
2240a string like "CORE::nonexistent_keyword" now passes UTF-8 and embedded
2241NULs through unchanged [perl #97478].
2242
2243=item *
2244
2245C<prototype> now treats magical variables like C<$1> the same way as
2246non-magical variables when checking for the CORE:: prefix, instead of
2247treating them as subroutine names.
2248
2249=item *
2250
2251Under threaded perls, a runtime code block in a regular expression could
2252corrupt the package name stored in the op tree, resulting in bad reads
2253in C<caller>, and possibly crashes [perl #113060].
2254
2255=item *
2256
2257Referencing a closure prototype (C<\&{$_[1]}> in an attribute handler for a
2258closure) no longer results in a copy of the subroutine (or assertion
2259failures on debugging builds).
2260
2261=item *
2262
2263C<eval '__PACKAGE__'> now returns the right answer on threaded builds if
2264the current package has been assigned over (as in
2265C<*ThisPackage:: = *ThatPackage::>) [perl #78742].
2266
2267=item *
2268
2269If a package is deleted by code that it calls, it is possible for C<caller>
2270to see a stack frame belonging to that deleted package. C<caller> could
2271crash if the stash's memory address was reused for a scalar and a
2272substitution was performed on the same scalar [perl #113486].
2273
2274=item *
2275
2276C<UNIVERSAL::can> no longer treats its first argument differently
2277depending on whether it is a string or number internally.
2278
2279=item *
2280
2281C<open> with C<< <& >> for the mode checks to see whether the third argument is
2282a number, in determining whether to treat it as a file descriptor or a handle
2283name. Magical variables like C<$1> were always failing the numeric check and
2284being treated as handle names.
2285
2286=item *
2287
2288C<warn>'s handling of magical variables (C<$1>, ties) has undergone several
2289fixes. C<FETCH> is only called once now on a tied argument or a tied C<$@>
2290[perl #97480]. Tied variables returning objects that stringify as "" are
2291no longer ignored. A tied C<$@> that happened to return a reference the
2292I<previous> time it was used is no longer ignored.
2293
2294=item *
2295
2296C<warn ""> now treats C<$@> with a number in it the same way, regardless of
2297whether it happened via C<$@=3> or C<$@="3">. It used to ignore the
2298former. Now it appends "\t...caught", as it has always done with
2299C<$@="3">.
2300
2301=item *
2302
2303Numeric operators on magical variables (e.g., S<C<$1 + 1>>) used to use
2304floating point operations even where integer operations were more appropriate,
2305resulting in loss of accuracy on 64-bit platforms [perl #109542].
2306
2307=item *
2308
2309Unary negation no longer treats a string as a number if the string happened
2310to be used as a number at some point. So, if C<$x> contains the string "dogs",
2311C<-$x> returns "-dogs" even if C<$y=0+$x> has happened at some point.
2312
2313=item *
2314
2315In Perl 5.14, C<-'-10'> was fixed to return "10", not "+10". But magical
2316variables (C<$1>, ties) were not fixed till now [perl #57706].
2317
2318=item *
2319
2320Unary negation now treats strings consistently, regardless of the internal
2321C<UTF8> flag.
2322
2323=item *
2324
2325A regression introduced in Perl v5.16.0 involving
2326C<tr/I<SEARCHLIST>/I<REPLACEMENTLIST>/> has been fixed. Only the first
2327instance is supposed to be meaningful if a character appears more than
2328once in C<I<SEARCHLIST>>. Under some circumstances, the final instance
2329was overriding all earlier ones. [perl #113584]
2330
2331=item *
2332
2333Regular expressions like C<qr/\87/> previously silently inserted a NUL
2334character, thus matching as if it had been written C<qr/\00087/>. Now it
2335matches as if it had been written as C<qr/87/>, with a message that the
2336sequence C<"\8"> is unrecognized.
2337
2338=item *
2339
2340C<__SUB__> now works in special blocks (C<BEGIN>, C<END>, etc.).
2341
2342=item *
2343
2344Thread creation on Windows could theoretically result in a crash if done
2345inside a C<BEGIN> block. It still does not work properly, but it no longer
2346crashes [perl #111610].
2347
2348=item *
2349
2350C<\&{''}> (with the empty string) now autovivifies a stub like any other
2351sub name, and no longer produces the "Unable to create sub" error
2352[perl #94476].
2353
37133b20
RS
2354=item *
2355
2356A regression introduced in v5.14.0 has been fixed, in which some calls
2357to the C<re> module would clobber C<$_> [perl #113750].
2358
2359=item *
2360
2361C<do FILE> now always either sets or clears C<$@>, even when the file can't be
2362read. This ensures that testing C<$@> first (as recommended by the
2363documentation) always returns the correct result.
2364
2365=item *
2366
2367The array iterator used for the C<each @array> construct is now correctly
2368reset when C<@array> is cleared (RT #75596). This happens for example when the
2369array is globally assigned to, as in C<@array = (...)>, but not when its
2370B<values> are assigned to. In terms of the XS API, it means that C<av_clear()>
2371will now reset the iterator.
2372
2373This mirrors the behaviour of the hash iterator when the hash is cleared.
2374
2375=item *
2376
2377C<< $class->can >>, C<< $class->isa >>, and C<< $class->DOES >> now return
2378correct results, regardless of whether that package referred to by C<$class>
2379exists [perl #47113].
2380
2381=item *
2382
2383Arriving signals no longer clear C<$@> [perl #45173].
2384
2385=item *
2386
2387Allow C<my ()> declarations with an empty variable list [perl #113554].
2388
2389=item *
2390
2391During parsing, subs declared after errors no longer leave stubs
2392[perl #113712].
2393
2394=item *
2395
2396Closures containing no string evals no longer hang on to their containing
2397subroutines, allowing variables closed over by outer subroutines to be
2398freed when the outer sub is freed, even if the inner sub still exists
2399[perl #89544].
2400
2401=item *
2402
2403Duplication of in-memory filehandles by opening with a "<&=" or ">&=" mode
2404stopped working properly in 5.16.0. It was causing the new handle to
2405reference a different scalar variable. This has been fixed [perl #113764].
2406
2407=item *
2408
2409C<qr//> expressions no longer crash with custom regular expression engines
2410that do not set C<offs> at regular expression compilation time
2411[perl #112962].
2412
2413=item *
2414
2415C<delete local> no longer crashes with certain magical arrays and hashes
2416[perl #112966].
2417
2418=item *
2419
2420C<local> on elements of certain magical arrays and hashes used not to
2421arrange to have the element deleted on scope exit, even if the element did
2422not exist before C<local>.
2423
2424=item *
2425
2426C<scalar(write)> no longer returns multiple items [perl #73690].
2427
2428=item *
2429
2430String to floating point conversions no longer misparse certain strings under
2431C<use locale> [perl #109318].
2432
2433=item *
2434
2435C<@INC> filters that die no longer leak memory [perl #92252].
2436
2437=item *
2438
2439The implementations of overloaded operations are now called in the correct
2440context. This allows, among other things, being able to properly override
2441C<< <> >> [perl #47119].
2442
2443=item *
2444
2445Specifying only the C<fallback> key when calling C<use overload> now behaves
2446properly [perl #113010].
2447
2448=item *
2449
2450C<< sub foo { my $a = 0; while ($a) { ... } } >> and
2451C<< sub foo { while (0) { ... } } >> now return the same thing [perl #73618].
2452
2453=item *
2454
2455Fixed the debugger C<l> and C<M> commands, and other debugger
2456functionality which was broken in 5.17.0 [perl #113918].
2457
2458=item *
2459
2460String negation now behaves the same under C<use integer;> as it does
2461without [perl #113012].
2462
2463=item *
2464
2465C<chr> now returns the Unicode replacement character (U+FFFD) for -1,
2466regardless of the internal representation. -1 used to wrap if the argument
2467was tied or a string internally.
2468
2469=item *
2470
2471Using a C<format> after its enclosing sub was freed could crash as of
2472perl 5.12.0, if the format referenced lexical variables from the outer sub.
2473
2474=item *
2475
2476Using a C<format> after its enclosing sub was undefined could crash as of
2477perl 5.10.0, if the format referenced lexical variables from the outer sub.
2478
2479=item *
2480
2481Using a C<format> defined inside a closures, which format references
2482lexical variables from outside, never really worked unless the C<write>
2483call was directly inside the closure. In 5.10.0 it even started crashing.
2484Now the copy of that closure nearest the top of the call stack is used to
2485find those variables.
2486
2487=item *
2488
2489Formats that close over variables in special blocks no longer crash if a
2490stub exists with the same name as the special block before the special
2491block is compiled.
2492
2493=item *
2494
2495The parser no longer gets confused, treating C<eval foo ()> as a syntax
2496error if preceded by C<print;> [perl #16249].
2497
2498=item *
2499
2500The return value of C<syscall> is no longer truncated on 64-bit platforms
2501[perl #113980].
2502
2503=item *
2504
2505Constant folding no longer causes C<print 1 ? FOO : BAR> to print to the
2506FOO handle [perl #78064].
2507
2508=item *
2509
2510C<do subname> now calls the named subroutine and uses the file name it
2511returns, instead of opening a file named "subname".
2512
2513=item *
2514
2515Subroutines looked up by rv2cv check hooks (registered by XS modules) are
2516now taken into consideration when determining whether C<foo bar> should be
2517the sub call C<foo(bar)> or the method call C<< "bar"->foo >>.
2518
2519=item *
2520
2521C<CORE::foo::bar> is no longer treated specially, allowing global overrides
2522to be called directly via C<CORE::GLOBAL::uc(...)> [perl #113016].
2523
2524=item *
2525
2526Calling an undefined sub whose typeglob has been undefined now produces the
2527customary "Undefined subroutine called" error, instead of "Not a CODE
2528reference".
2529
2530=item *
2531
2532Two bugs involving @ISA have been fixed. C<*ISA = *glob_without_array> and
2533C<undef *ISA; @{*ISA}> would prevent future modifications to @ISA from
2534updating the internal caches used to look up methods. The
2535*glob_without_array case was a regression from Perl 5.12.
2536
2537=item *
2538
2539Regular expression optimisations sometimes caused C<$> with C</m> to
2540produce failed or incorrect matches [perl #114068].
2541
2542=item *
2543
2544C<__SUB__> now works in a C<sort> block when the enclosing subroutine is
2545predeclared with C<sub foo;> syntax [perl #113710].
2546
2547=item *
2548
2549Unicode properties only apply to Unicode code points, which leads to
2550some subtleties when regular expressions are matched against
2551above-Unicode code points. There is a warning generated to draw your
2552attention to this. However, this warning was being generated
2553inappropriately in some cases, such as when a program was being parsed.
2554Non-Unicode matches such as C<\w> and C<[:word;]> should not generate the
2555warning, as their definitions don't limit them to apply to only Unicode
2556code points. Now the message is only generated when matching against
2557C<\p{}> and C<\P{}>. There remains a bug, [perl #114148], for the very
2558few properties in Unicode that match just a single code point. The
2559warning is not generated if they are matched against an above-Unicode
2560code point.
2561
7e7c78a1
RS
2562=item *
2563
2564Uninitialized warnings mentioning hash elements would only mention the
2565element name if it was not in the first bucket of the hash, due to an
2566off-by-one error.
2567
2568=item *
2569
2570A regular expression optimizer bug could cause multiline "^" to behave
2571incorrectly in the presence of line breaks, such that
2572C<"/\n\n" =~ m#\A(?:^/$)#im> would not match [perl #115242].
2573
2574=item *
2575
2576Failed C<fork> in list context no longer currupts the stack.
2577C<@a = (1, 2, fork, 3)> used to gobble up the 2 and assign C<(1, undef, 3)>
2578if the C<fork> call failed.
2579
2580=item *
2581
2582Numerous memory leaks have been fixed, mostly involving tied variables that
2583die, regular expression character classes and code blocks, and syntax
2584errors.
2585
2586=item *
2587
2588Assigning a regular expression (C<${qr//}>) to a variable that happens to
2589hold a floating point number no longer causes assertion failures on
2590debugging builds.
2591
2592=item *
2593
2594Assigning a regular expression to a scalar containing a number no longer
2595causes subsequent nummification to produce random numbers.
2596
2597=item *
2598
2599Assigning a regular expression to a magic variable no longer wipes away the
2600magic. This is a regression from 5.10.
2601
2602=item *
2603
2604Assigning a regular expression to a blessed scalar no longer results in
2605crashes. This is also a regression from 5.10.
2606
2607=item *
2608
2609Regular expression can now be assigned to tied hash and array elements with
2610flattening into strings.
2611
2612=item *
2613
2614Nummifying a regular expression no longer results in an uninitialized
2615warning.
2616
2617=item *
2618
2619Negative array indices no longer cause EXISTS methods of tied variables to
2620be ignored. This is a regression from 5.12.
2621
2622=item *
2623
2624Negative array indices no longer result in crashes on arrays tied to
2625non-objects.
2626
2627=item *
2628
2629C<$x = "(?{})"; /a++(?{})+$x/x> no longer erroneous produces an error (just
2630a warning, as expected). This was broken in 5.17.1.
2631
2632=item *
2633
2634C<$byte_overload .= $utf8> no longer results in doubly-encoded UTF8 if the
2635left-hand scalar happened to have produced a UTF8 string the last time
2636overloading was invoked.
2637
2638=item *
2639
2640C<goto &sub> now uses the current value of @_, instead of using the array
2641the subroutine was originally called with. This means
2642C<local @_ = (...); goto &sub> now works [perl #43077].
2643
2644=item *
2645
2646If a debugger is invoked recursively, it no longer stomps on its own
2647lexical variables. Formerly under recursion all calls would share the same
2648set of lexical variables [perl #115742].
2649
2650=item *
2651
2652C<*_{ARRAY}> returned from a subroutine no longer spontaneously
2653becomes empty.
2654
e5ba1bf1
FC
2655=back
2656
0bba4573 2657=head1 Known Problems
e5ba1bf1 2658
0bba4573
RS
2659XXX Descriptions of platform agnostic bugs we know we can't fix go here. Any
2660tests that had to be C<TODO>ed for the release would be noted here. Unfixed
2661platform specific bugs also go here.
2662
2663[ List each fix as a =item entry ]
2664
2665=over 4
2666
2667=item *
2668
2669XXX
2670
2671=back
e5ba1bf1
FC
2672
2673=head1 Acknowledgements
2674
2675XXX Generate this with:
2676
de3d8d88 2677 perl Porting/acknowledgements.pl v5.17.12..HEAD
e5ba1bf1
FC
2678
2679=head1 Reporting Bugs
2680
2681If you find what you think is a bug, you might check the articles recently
2682posted to the comp.lang.perl.misc newsgroup and the perl bug database at
2683http://rt.perl.org/perlbug/ . There may also be information at
2684http://www.perl.org/ , the Perl Home Page.
2685
2686If you believe you have an unreported bug, please run the L<perlbug> program
2687included with your release. Be sure to trim your bug down to a tiny but
2688sufficient test case. Your bug report, along with the output of C<perl -V>,
2689will be sent off to perlbug@perl.org to be analysed by the Perl porting team.
2690
2691If the bug you are reporting has security implications, which make it
2692inappropriate to send to a publicly archived mailing list, then please send it
2693to perl5-security-report@perl.org. This points to a closed subscription
2694unarchived mailing list, which includes all the core committers, who will be
2695able to help assess the impact of issues, figure out a resolution, and help
2696co-ordinate the release of patches to mitigate or fix the problem across all
2697platforms on which Perl is supported. Please only use this address for
2698security issues in the Perl core, not for modules independently distributed on
2699CPAN.
2700
2701=head1 SEE ALSO
2702
2703The F<Changes> file for an explanation of how to view exhaustive details on
2704what changed.
2705
2706The F<INSTALL> file for how to build Perl.
2707
2708The F<README> file for general stuff.
2709
2710The F<Artistic> and F<Copying> files for copyright information.
2711
2712=cut