argra****@users*****
argra****@users*****
2012年 4月 22日 (日) 01:11:47 JST
Index: docs/perl/5.16.0/perl5160delta.pod diff -u docs/perl/5.16.0/perl5160delta.pod:1.2 docs/perl/5.16.0/perl5160delta.pod:1.3 --- docs/perl/5.16.0/perl5160delta.pod:1.2 Sat Apr 21 21:09:04 2012 +++ docs/perl/5.16.0/perl5160delta.pod Sun Apr 22 01:11:47 2012 @@ -201,7 +201,7 @@ (C<substr> 左辺å¤ã®å·æ°) -=for comment Can this be compacted some? -- rjbs, 2012-02-20 +=for comment Does this belong here, or under Incomptable Changes? =begin original @@ -243,15 +243,11 @@ =begin original -These changes result in several incompatible changes and bug fixes: +These changes result in an incompatible change: =end original -ãããã®å¤æ´ã¯ããã¤ãã®äºææ§ã®ãªãå¤æ´ã¨ãã°ä¿®æ£ãèµ·ããã¾ã: - -=over - -=item * +ãããã®å¤æ´ã¯ããã¤ãã®äºææ§ã®ãªãå¤æ´ãå¼ãèµ·ããã¾ã: =begin original @@ -283,98 +279,20 @@ è¿ããã左辺å¤ã¯ããã¨ãæååãé·ããªã£ã¦ãã常ã«æååã®æ«å°¾ã« æ¡å¼µããã¾ãã -=item * - -=begin original - -Tied (and otherwise magical) variables are no longer exempt from the -"Attempt to use reference as lvalue in substr" warning. - -=end original - -tie ããã (ããã³ãã®ä»ã®ãã¸ã«ã«ãª) å¤æ°ã¯ãã¯ã -"Attempt to use reference as lvalue in substr" ã¨ããè¦åã -åºããªããªãã¾ããã - -=item * - -=begin original - -That warning now occurs when the returned lvalue is assigned to, not -when C<substr> itself is called. This only makes a difference if the -return value of C<substr> is referenced and assigned to later. - -=end original - -ãã®è¦åã¯ãC<substr> èªèº«ãå¼ã³åºãããã¨ãã§ã¯ãªãã左辺å¤ã -ä»£å ¥ãããã¨ãã«çºçãã¾ãã -ããã«ããéãã¯ãC<substr> ã®è¿ãå¤ããªãã¡ã¬ã³ã¹ããã¦ããã®å¾ã§ -ä»£å ¥ãããã¨ãã®ã¿ã§ãã - -=item * - -=begin original - -The order in which "uninitialized" warnings occur for arguments to -C<substr> has changed. - -=end original - -C<substr> ã®å¼æ°ã«å¯¾ã㦠"uninitialized" è¦åãåºãé çªãå¤æ´ããã¾ããã - -=item * - -=begin original - -Passing a substring of a read-only value or a typeglob to a function -(potential lvalue context) no longer causes an immediate "Can't coerce" -or "Modification of a read-only value" error. That error only occurs -if and when the value passed is assigned to. - -=end original - -èªã¿è¾¼ã¿å°ç¨ã®å¤ãåã°ããã®é¨åæååã(æ½å¨çã«å·¦è¾ºå¤ã³ã³ããã¹ãã«ãªã) -é¢æ°ã«æ¸¡ãã¦ããç´ã¡ã« "Can't coerce" ã -"Modification of a read-only value" ã¨ã©ã¼ãçºçãããªããªãã¾ããã -ãã®ã¨ã©ã¼ã¯æ¸¡ãããå¤ãä»£å ¥ãããæã«ã ãçºçãã¾ãã - -=begin original - -The same thing happens with the "substr outside of string" error. If -the lvalue is only read, not written to, it is now just a warning, as -with rvalue C<substr>. - -=end original - -åããã¨ã¯ "substr outside of string" ã¨ã©ã¼ã§èµ·ããã¾ãã -左辺å¤ãèªã¿è¾¼ã¾ããã ãã§æ¸ãè¾¼ã¾ããªããªããå³è¾ºå¤ã® C<substr> ã¨åæ§ã -åã«è¦åã ããåºãããã«ãªãã¾ããã - -=item * - -=begin original - -C<substr> assignments no longer call FETCH twice if the first argument -is a tied variable, just once. - -=end original - -C<substr> ä»£å ¥ã¯ã第ä¸å¼æ°ãs tie ãããå¤æ°ã®å ´åã« FETCH ã 2 å -å¼ã³åºããããã¨ã¯ãªããªãã1 åã ãã«ãªãã¾ããã - -=back - =begin original -It was impossible to fix all the bugs without an incompatible change, -and the behaviour of negative offsets was never specified, so the +Since this change also allowed many bugs to be fixed (see +L</Fixes to the C<substr> operator>), and since the behaviour +of negative offsets has never been specified, so the change was deemed acceptable. =end original -äºææ§ã®ãªããªãå¤æ´ãªãã«å ¨ã¦ã®ãã°ãä¿®æ£ãããã¨ã¯ä¸å¯è½ã§ã -è² æ°ã®ãªãã»ããã¯ä»æ§ã«ãªã£ããã¨ã¯ãªãã®ã§ããã®å¤æ´ã¯åãå ¥ãããã -åå¼ã§ããã +Since this change also allowed many bugs to be fixed (see +L</Fixes to the C<substr> operator>), +è² æ°ã®ãªãã»ããã®æ¯ãèãã¯ä»æ§ã«ãªã£ããã¨ã¯ãªãã®ã§ããã®å¤æ´ã¯ +åãå ¥ããããåå¼ã§ããã +(TBT) =head3 Return value of C<tied> @@ -662,16 +580,6 @@ =item * -=begin original - -Constant subroutine names (not null-clean yet) - -=end original - -å®æ°ãµãã«ã¼ãã³å(ã¾ã ãã«ã¯ãªã¼ã³ã§ã¯ããã¾ãã) - -=item * - C<goto> =item * @@ -708,16 +616,6 @@ =begin original -Package names returned by C<caller()> - -=end original - -C<caller()> ããè¿ãããããã±ã¼ã¸å - -=item * - -=begin original - Subroutine prototypes =end original @@ -1372,7 +1270,7 @@ ãã®ãã°ã¯ C<setresgid()> ã¯ããããã©ã C<setregid()> ããªãã·ã¹ãã ã«ã®ã¿ å½±é¿ãä¸ãã¾ããããã®ãããªã·ã¹ãã ã¯ç¥ããã¦ãã¾ããã -=head1 Deprecation +=head1 Deprecations (éæ¨å¥¨) @@ -1754,44 +1652,18 @@ The C<*{...}> operator, when passed a reference to an IO thingy (as in C<*{*STDIN{IO}}>), creates a new typeglob containing just that IO object. - -=end original - -C<*{...}> æ¼ç®åã¯ã(C<*{*STDIN{IO}}> ã®ãããª) IO ç³»ã¸ã®ãªãã¡ã¬ã³ã¹ã -渡ãã¨ãIO ãªãã¸ã§ã¯ãèªä½ãå«ãæ°ããåã°ãããä½æãã¾ãã - -=begin original - Previously, it would stringify as an empty string, but some operators would treat it as undefined, producing an "uninitialized" warning. Now it stringifies as __ANONIO__ [perl #96326]. =end original +C<*{...}> æ¼ç®åã¯ã(C<*{*STDIN{IO}}> ã®ãããª) IO ç³»ã¸ã®ãªãã¡ã¬ã³ã¹ã +渡ãã¨ãIO ãªãã¸ã§ã¯ãèªä½ãå«ãæ°ããåã°ãããä½æãã¾ãã 以åã¯ã空æååã¨ãã¦æåååãã¦ãã¾ããããä¸é¨ã®æ¼ç®åã¯ããã æªå®ç¾©ã¨ãã¦æ±ãã"uninitialized" è¦åãåºåãã¦ãã¾ããã ä»ã§ã¯ __ANONIO__ ã¨æåååããã¾ã [perl #96326]ã -=begin original - -Having a typeglob appear as an empty string is a side effect of the -implementation that has caused various bugs over the years. - -=end original - -åã°ããã空æååã«ãªããã¨ã¯ãé·å¹´ã«ããã£ã¦æ§ã ãªãã°ãå¼ãèµ·ããã¦ãã -å®è£ ä¸ã®å¯ä½ç¨ã§ãã - -=begin original - -The solution was to make it stringify like a normal anonymous typeglob, -like those produced by C<< open($foo->{bar}, ...) >> [perl #96326]. - -=end original - -解決æ³ã¯ãC<< open($foo->{bar}, ...) >> ã§çæãããããã«ã -é常ã®ç¡ååã°ããã®ããã«æåååãããã¨ã§ã [perl #96326]ã - =head2 User-defined case changing operations. (ã¦ã¼ã¶ã¼å®ç¾©å¤§æåå¤æ´æä½) @@ -2057,10 +1929,6 @@ C<substr> no longer calculates a value to return when called in void context. -=back - -=over 4 - =item * Due to changes in L<File::Glob>, Perl's C<glob> function and its C<< @@ -2282,12 +2150,6 @@ =item * -The section on the triple-dot or yada-yada operator has been moved up, as -it used to separate two closely related sections about the comma operator -(5.14.1). - -=item * - More examples for C<m//g> have been added (5.14.1). =item * @@ -2388,11 +2250,6 @@ =item * -The L<perlsub/"Lvalue subroutines"> section has been amended to reflect -the many changes present in 5.16.0. - -=item * - The ($;) prototype syntax, which has existed for rather a long time, is now documented in L<perlsub>. It allows a unary function to have the same precedence as a list operator. @@ -2454,36 +2311,17 @@ =head2 Removed Documentation -(åé¤ãããææ¸) - =head3 Old OO Documentation -(å¤ã OO ææ¸) - -=begin original - All the old OO tutorials, perltoot, perltooc, and perlboot, have been removed. The perlbot (bag of object tricks) document has been removed as well. -=end original - -å¤ã OO ãã¥ã¼ããªã¢ã«ã§ãã perltoot, perltooc, perlboot ã¯åé¤ããã¾ããã -perlbot (bag of object tricks) ææ¸ãåé¤ããã¾ããã - =head3 Development Deltas -=begin original - The perldelta files for development releases are no longer packaged with perl. These can still be found in the perl source code repository. -=end original - -éçºãªãªã¼ã¹ã® perldelta ãã¡ã¤ã«ã¯ perl ã¨å ±ã« -ããã±ã¼ã¸ã³ã°ãããªããªãã¾ããã -perl ã½ã¼ã¹ã³ã¼ãã¬ãã¸ããªã«ã¯æ®ã£ã¦ãã¾ãã - =head1 Diagnostics The following additions or changes have been made to diagnostic output, @@ -2974,6 +2812,8 @@ =head2 Regular expressions and character classes +XXX Is it possible to merge some of these items? + =over 4 =item * @@ -2984,11 +2824,6 @@ =item * -C</.*/g> would sometimes refuse to match at the end of a string that ends -with "\n". This has been fixed [perl #109206]. - -=item * - C<m/[[:ascii:]]/i> and C</\p{ASCII}/i> now match identically (when not under a differing locale). This fixes a regression introduced in 5.14 in which the first expression could match characters outside of ASCII, @@ -2996,6 +2831,11 @@ =item * +C</.*/g> would sometimes refuse to match at the end of a string that ends +with "\n". This has been fixed [perl #109206]. + +=item * + Starting with 5.12.0, Perl used to get its internal bookkeeping muddled up after assigning C<${ qr// }> to a hash element and locking it with L<Hash::Util>. This could result in double frees, crashes or erratic @@ -3061,89 +2901,230 @@ of a Unicode property. That property wasn't getting inverted outside the Latin1 range. -=back +=item * -=head2 Formats +Three problematic Unicode characters now work better in regex pattern matching under C</i> -=over +In the past, three Unicode characters: +LATIN SMALL LETTER SHARP S, +GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS, +and +GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS, +along with the sequences that they fold to +(including "ss" in the case of LATIN SMALL LETTER SHARP S), +did not properly match under C</i>. 5.14.0 fixed some of these cases, +but introduced others, including a panic when one of the characters or +sequences was used in the C<(?(DEFINE)> regular expression predicate. +The known bugs that were introduced in 5.14 have now been fixed; as well +as some other edge cases that have never worked until now. All these +involve using the characters and sequences outside bracketed character +classes under C</i>. This closes [perl #98546]. + +There remain known problems when using certain characters with +multi-character folds inside bracketed character classes, including such +constructs as C<qr/[\N{LATIN SMALL LETTER SHARP}a-z]/i>. These +remaining bugs are addressed in [perl #89774]. =item * -A number of edge cases have been fixed with formats and C<formline>; -in particular, where the format itself is potentially variable (such as -with ties and overloading), and where the format and data differ in their -encoding. In both these cases, it used to possible for the output to be -corrupted [perl #91032]. +RT #78266: The regex engine has been leaking memory when accessing +named captures that weren't matched as part of a regex ever since 5.10 +when they were introduced, e.g. this would consume over a hundred MB of +memory: + + for (1..10_000_000) { + if ("foo" =~ /(foo|(?<capture>bar))?/) { + my $capture = $+{capture} + } + } + system "ps -o rss $$"' =item * -C<formline> no longer converts its argument into a string in-place. So -passing a reference to C<formline> no longer destroys the reference -[perl #79532]. +In 5.14, C</[[:lower:]]/i> and C</[[:upper:]]/i> no longer matched the +opposite case. This has been fixed [perl #101970]. -=back +=item * -=head2 Copy-on-write scalars +A regular expression match with an overloaded object on the right-hand side +would in some cases stringify the object too many times. -Copy-on-write scalars were introduced in 5.8.0, but most Perl code -did not encounter them (they were used mostly internally). Perl -5.10.0 extended them, such that assigning C<__PACKAGE__> or a -hash key to a scalar would make it copy-on-write. Several parts -of Perl were not updated to account for them, but have now been fixed. +=item * -=over +A regression has been fixed that was introduced in 5.14, in C</i> +regular expression matching, in which a match improperly fails if the +pattern is in UTF-8, the target string is not, and a Latin-1 character +precedes a character in the string that should match the pattern. +[perl #101710] =item * -C<utf8::decode> had a nasty bug that would modify copy-on-write scalars' -string buffers in place (i.e., skipping the copy). This could result in -hashes having two elements with the same key [perl #91834]. +In case-insensitive regular expression pattern matching, no longer on +UTF-8 encoded strings does the scan for the start of match only look at +the first possible position. This caused matches such as +C<"f\x{FB00}" =~ /ff/i> to fail. =item * -Lvalue subroutines were not allowing COW scalars to be returned. This was -fixed for lvalue scalar context in Perl 5.12.3 and 5.14.0, but list context -was not fixed until this release. +The regexp optimiser no longer crashes on debugging builds when merging +fixed-string nodes with inconvenient contents. =item * -Elements of restricted hashes (see the L<fields> pragma) containing -copy-on-write values couldn't be deleted, nor could such hashes be cleared -(C<%hash = ()>). +A panic involving the combination of the regular expression modifiers +C</aa> and the C<\b> escape sequence introduced in 5.14.0 has been +fixed [perl #95964]. =item * -Localising a tied variable used to make it read-only if it contained a -copy-on-write string. +The combination of the regular expression modifiers C</aa> and the C<\b> +and C<\B> escape sequences did not work properly on UTF-8 encoded +strings. All non-ASCII characters under C</aa> should be treated as +non-word characters, but what was happening was that Unicode rules were +used to determine wordness/non-wordness for non-ASCII characters. This +is now fixed [perl #95968]. =item * -L<Storable>, L<Devel::Peek> and L<PerlIO::scalar> had similar problems. -See L</Updated Modules and Pragmata>, above. +C<< (?foo: ...) >> no longer loses passed in character set. -XXX That section is empty. +=item * -=back +The trie optimisation used to have problems with alternations containing +an empty C<(?:)>, causing C<< "x" =~ /\A(?>(?:(?:)A|B|C?x))\z/ >> not to +match, whereas it should [perl #111842]. -=head2 Lvalue subroutines +=item * -There have been various fixes to lvalue subroutines. +Use of lexical (C<my>) variables in code blocks embedded in regular +expressions will no longer result in memory corruption or crashes. -=over +Nevertheless, these code blocks are still experimental, as there are still +problems with the wrong variables being closed over (in loops for instance) +and with abnormal exiting (e.g., C<die>) causing memory corruption. =item * -Explicit return now returns the actual argument passed to return, instead -of copying it [perl #72724, #72706]. +The C<\h>, C<\H>, C<\v> and C<\V> regular expression metacharacters used to +cause a panic error message when attempting to match at the end of the +string [perl #96354]. =item * -Lvalue subroutines used to enforce lvalue syntax (i.e., whatever can go on -the left-hand side of C<=>) for the last statement and the arguments to -return. Since lvalue subroutines are not always called in lvalue context, -this restriction has been lifted. +The abbreviations for four C1 control characters C<MW> C<PM>, C<RI>, and +C<ST> were previously unrecognized by C<\N{}>, vianame(), and +string_vianame(). -=item * +=back + +=head2 Formats + +=over + +=item * + +A number of edge cases have been fixed with formats and C<formline>; +in particular, where the format itself is potentially variable (such as +with ties and overloading), and where the format and data differ in their +encoding. In both these cases, it used to possible for the output to be +corrupted [perl #91032]. + +=item * + +C<formline> no longer converts its argument into a string in-place. So +passing a reference to C<formline> no longer destroys the reference +[perl #79532]. + +=item * + +Assignment to C<$^A> (the format output accumulator) now recalculates +the number of lines output. + +=back + +=head2 Copy-on-write scalars + +Copy-on-write or shared hash key scalars +were introduced in 5.8.0, but most Perl code +did not encounter them (they were used mostly internally). Perl +5.10.0 extended them, such that assigning C<__PACKAGE__> or a +hash key to a scalar would make it copy-on-write. Several parts +of Perl were not updated to account for them, but have now been fixed. + +=over + +=item * + +C<utf8::decode> had a nasty bug that would modify copy-on-write scalars' +string buffers in place (i.e., skipping the copy). This could result in +hashes having two elements with the same key [perl #91834]. + +=item * + +Lvalue subroutines were not allowing COW scalars to be returned. This was +fixed for lvalue scalar context in Perl 5.12.3 and 5.14.0, but list context +was not fixed until this release. + +=item * + +Elements of restricted hashes (see the L<fields> pragma) containing +copy-on-write values couldn't be deleted, nor could such hashes be cleared +(C<%hash = ()>). + +=item * + +Localising a tied variable used to make it read-only if it contained a +copy-on-write string. + +=item * + +Assigning a copy-on-write string to a stash +element no longer causes a double free. Regardless of this change, the +results of such assignments are still undefined. + +=item * + +Assigning a copy-on-write string to a tied variable no longer stops that +variable from being tied if it happens to be a PVMG or PVLV internally. + +=item * + +Doing a substitution on a tied variable returning a copy-on-write +scalar used to cause an assertion failure or an "Attempt to free +nonexistent shared string" warning. + +=item * + +This one is a regression from 5.12: In 5.14.0, the bitwise assignment +operators C<|=>, C<^=> and C<&=> started leaving the left-hand side +undefined if it happened to be a copy-on-write string [perl #108480]. + +=item * + +L<Storable>, L<Devel::Peek> and L<PerlIO::scalar> had similar problems. +See L</Updated Modules and Pragmata>, above. + +XXX That section is empty. + +=back + +=head2 Lvalue subroutines + +=over + +=item * + +Explicit return now returns the actual argument passed to return, instead +of copying it [perl #72724, #72706]. + +=item * + +Lvalue subroutines used to enforce lvalue syntax (i.e., whatever can go on +the left-hand side of C<=>) for the last statement and the arguments to +return. Since lvalue subroutines are not always called in lvalue context, +this restriction has been lifted. + +=item * Lvalue subroutines are less restrictive as to what values can be returned. It used to croak on values returned by C<shift> and C<delete> and from @@ -3259,7 +3240,7 @@ =item * C<eval $string> and C<require> used not to -localise C<%^H> when compiling its argument if it +localise C<%^H> during compilation if it was empty at the time the C<eval> call itself was compiled. This could lead to scary side effects, like C<use re "/m"> enabling other flags that the surrounding code was trying to enable for its caller [perl #68750]. @@ -3337,6 +3318,14 @@ It used to be possible to free the typeglob of a localised array or hash (e.g., C<local @{"x"}; delete $::{x}>), resulting in a crash on scope exit. +=item * + +Some core bugs affecting L<Hash::Util> have been fixed: locking a hash +element that is a glob copy no longer causes subsequent assignment to it to +corrupt the glob, and unlocking a hash element that holds a copy-on-write +scalar no longer causes modifications to that scalar to modify other +scalars that were sharing the same string buffer. + =back =head2 Weak references @@ -3424,7 +3413,19 @@ C<stat> produces more consistent warnings. It no longer warns for "_" [perl #71002] and no longer skips the warning at times for other unopened -handles. +handles. It no longer warns about an unopened handle when the operating +system's C<fstat> function fails. + +=item * + +C<stat> would sometimes return negative numbers for large inode numbers, +because it was using the wrong internal C type. [perl #84590] + +=item * + +C<lstat> is documented to fall back to C<stat> (with a warning) when given +a filehandle. When passed an IO reference, it was actually doing the +equivalent of S<C<stat _>> and ignoring the handle. =item * @@ -3434,12 +3435,34 @@ =item * -C<-T>, C<-B> and C<-t> now work when stacked with other filetest operators +C<-T>, C<-B>, C<-l> and C<-t> now work +when stacked with other filetest operators [perl #77388]. =item * -Stacked filetest operators now only call FETCH once on a tied argument. +In 5.14.0, filetest ops (C<-r>, C<-x>, etc.) started calling FETCH on a +tied argument belonging to the previous argument to a list operator, if +called with a bareword argument or no argument at all. This has been +fixed, so C<push @foo, $tied, -r> no longer calls FETCH on C<$tied>. + +=item * + +In Perl 5.6, C<-l> followed by anything other than a bareword would treat +its argument as a file name. That was changed in 5.8 for glob references +(C<\*foo>), but not for globs themselves (C<*foo>). C<-l> started +returning C<undef> for glob references without setting the last +stat buffer that the "_" handle uses, but only if warnings +were turned on. With warnings off, it was the same as 5.6. +In other words, it was simply buggy and inconsistent. Now the 5.6 +behaviour has been restored. + +=item * + +C<-l> followed by a bareword no longer "eats" the previous argument to +the list operator in whose argument list it resides. Hence, +C<print "bar", -l foo> now actually prints "bar", because C<-l> +on longer eats it. =item * @@ -3490,349 +3513,259 @@ These have all been fixed. -=item * +=back -C<stat I<HANDLE>> and fstat failures +=head2 Version objects and vstrings -If the operating system's C<fstat> function failed, C<stat> would warn -about an unopened handle, even though that was not the case. This has been -fixed. +=over =item * -C<lstat I<IOREF>> - -C<lstat> is documented to fall back to C<stat> (with a warning) when given -a filehandle. When passed an IO reference, it was actually doing the -equivalent of S<C<stat _>> and ignoring the handle. +The bitwise complement operator (and possibly other operators, too) when +passed a vstring would leave vstring magic attached to the return value, +even though the string had changed. This meant that +C<< version->new(~v1.2.3) >> would create a version looking like "v1.2.3" +even though the string passed to C<< version->new >> was actually +"\376\375\374". This also caused L<B::Deparse> to deparse C<~v1.2.3> +incorrectly, without the C<~> [perl #29070]. =item * -stat() would always return the inode number as an IV, even when the -original was unsigned, or too large to fit in an IV. stat() now -returns the inode number as the type that would best preserve the -original value. [perl #84590] +Assigning a vstring to a magic (e.g., tied, C<$!>) variable and then +assigning something else used to blow away all the magic. This meant that +tied variables would come undone, C<$!> would stop getting updated on +failed system calls, C<$|> would stop setting autoflush, and other +mischief would take place. This has been fixed. =item * -In 5.14.0, filetest ops (C<-r>, C<-x>, etc.) started calling FETCH on a -tied argument belonging to the previous argument to a list operator, if -called with a bareword argument or no argument at all. This has been -fixed, so C<push @foo, $tied, -r> no longer calls FETCH on C<$tied>. +C<< version->new("version") >> and C<printf "%vd", "version"> no longer +crash [perl #102586]. =item * -Stacked C<-l> (followed immediately by other filetest operators) did not -work previously; now it does. It is only permitted when the rightmost -filetest op has the special "_" handle for its argument and the most -recent C<stat>/C<lstat> call was an C<lstat>. +Version comparisons, such as those that happen implicitly with C<use +v5.43>, no longer cause locale settings to change [perl #105784]. =item * -In Perl 5.6, C<-l> followed by anything other than a bareword would treat -its argument as a file name. That was changed in 5.8 for glob references -(C<\*foo>), but not for globs themselves (C<*foo>). C<-l> started -returning C<undef> for glob references without setting the last -stat buffer that the "_" handle uses, but only if warnings -were turned on. With warnings off, it was the same as 5.6. -In other words, it was simply buggy and inconsistent. Now the 5.6 -behaviour has been restored. +Version objects no longer cause memory leaks in boolean context +[perl #109762]. =back -=head2 Other notable fixes +=head2 Tied variables =over =item * -Last-accessed filehandle - -Perl has an internal variable that stores the last filehandle to be -accessed. It is used by C<$.> and by C<tell> and C<eof> without -arguments. +Various cases in which FETCH was being ignored or called too many times +have been fixed: -It used to be possible to set this internal variable to a glob copy and -then modify that glob copy to be something other than a glob, and still -have the last-accessed filehandle associated with the variable after -assigning a glob to it again: +=over - my $foo = *STDOUT; # $foo is a glob copy - <$foo>; # $foo is now the last-accessed handle - $foo = 3; # no longer a glob - $foo = *STDERR; # still the last-accessed handle +=item * -Now the C<$foo = 3> assignment unsets that internal variable, so there -is no last-accessed filehandle, just as if C<< <$foo> >> had never -happened. +C<PerlIO::get_layers> [perl #97956] =item * -C<~~> now correctly handles the precedence of Any~~Object, and is not tricked -by an overloaded object on the left-hand side. +C<$tied =~ y/a/b/>, C<chop $tied> and C<chomp $tied> when $tied holds a +reference. =item * -C<quotemeta> now quotes consistently the same non-ASCII characters under -C<use feature 'unicode_strings'>, regardless of whether the string is -encoded in UTF-8 or not, hence fixing the last vestiges (we hope) of the -infamous L<perlunicode/The "Unicode Bug">. [perl #77654]. - -Which of these code points is quoted has changed, based on Unicode's -recommendations. See L<perlfunc/quotemeta> for details. +Four-argument C<select> =item * -C<~> on vstrings - -The bitwise complement operator (and possibly other operators, too) when -passed a vstring would leave vstring magic attached to the return value, -even though the string had changed. This meant that -C<< version->new(~v1.2.3) >> would create a version looking like "v1.2.3" -even though the string passed to C<< version->new >> was actually -"\376\375\374". This also caused L<B::Deparse> to deparse C<~v1.2.3> -incorrectly, without the C<~> [perl #29070]. +A tied buffer passed to C<sysread> =item * -Vstrings blowing away magic +C<< $tied .= <> >> -Assigning a vstring to a magic (e.g., tied, C<$!>) variable and then -assigning something else used to blow away all the magic. This meant that -tied variables would come undone, C<$!> would stop getting updated on -failed system calls, C<$|> would stop setting autoflush, and other -mischief would take place. This has been fixed. +=item * + +Three-argument C<open>, the third being a tied file handle +(as in C<< open $fh, ">&", $tied >>) =item * -C<newHVhv> and tied hashes +C<sort> with a reference to a tied glob for the comparison routine. -The C<newHVhv> XS function now works on tied hashes, instead of crashing or -returning an empty hash. +=item * + +C<..> and C<...> in list context [perl #53554]. =item * -No warning for C<open(foo::bar)> +C<${$tied}>, C<@{$tied}>, C<%{$tied}> and C<*{$tied}> where the tied +variable returns a string (C<&{}> was unaffected) -When one writes C<open foo || die>, which used to work in Perl 4, a -"Precedence problem" warning is produced. This warning used erroneously to -apply to fully-qualified bareword handle names not followed by C<||>. This -has been corrected. +=item * + +C<defined ${ $tied_variable }> =item * -C<select> and package aliasing +Various functions that take a filehandle argument in rvalue context +(C<close>, C<readline>, etc.) [perl #97482] -After package aliasing (C<*foo:: = *bar::>), C<select> with 0 or 1 argument -would sometimes return a name that could not be used to refer to the -filehandle, or sometimes it would return C<undef> even when a filehandle -was selected. Now it returns a typeglob reference in such cases. +=item * + +Some cases of dereferencing a complex expression, such as +C<${ (), $tied } = 1>, used to call C<FETCH> multiple times, but now call +it once. =item * -C<PerlIO::get_layers> and tied variables +C<$tied-E<gt>method> where $tied returns a package name--even resulting in +a failure to call the method, due to memory corruption -C<PerlIO::get_layers> no longer ignores FETCH on tied variables as it used -to most of the time [perl #97956]. +=item * + +Assignments like C<*$tied = \&{"..."}> and C<*glob = $tied> =item * -C<PerlIO::get_layers> and numbers +C<chdir>, C<chmod>, C<chown>, C<utime>, C<truncate>, C<stat>, C<lstat> and +the filetest ops (C<-r>, C<-x>, etc.) -C<PerlIO::get_layers> no longer ignores some arguments that it thinks are -numeric, while treating others as filehandle names. It is now consistent -for flat scalars (i.e., not references). +=back =item * -C<caller> and tied C<@DB::args> - C<caller> sets C<@DB::args> to the subroutine arguments when called from the DB package. It used to crash when doing so if C<@DB::args> happened to be tied. Now it croaks instead. =item * -Tying C<@_> - -Under debugging builds, this code: - - sub TIEARRAY{bless[]} - sub { - tie @_, ""; - \@_; - }->(1); - -use to produce an "av_reify called on tied array" warning. It doesn't any -more. +Tying an element of %ENV or C<%^H> and then deleting that element would +result in a call to the tie object's DELETE method, even though tying the +element itself is supposed to be equivalent to tying a scalar (the element +is, of course, a scalar) [perl #67490]. =item * -Unrecognised switches on C<#!> line - -If a switch, such as B<-x>, that cannot occur on the C<#!> line is used -there, perl dies with "Can't emulate...". - -It used to produce the same message for switches that perl did not -recognise at all, whether on the command line or the C<#!> line. - -Now it produces the "Unrecognized switch" error message [perl #104288]. +When Perl autovivifies an element of a tied array or hash (which entails +calling STORE with a new reference), it now calls FETCH immediately after +the STORE, instead of assuming that FETCH would have returned the same +reference. This can make it easier to implement tied objects [perl #35865, #43011]. =item * -C<system> and SIGCHLD - -C<system> now temporarily blocks the SIGCHLD signal handler, to prevent the -signal handler from stealing the exit status [perl #105700]. +Four-argument C<select> no longer produces its "Non-string passed as +bitmask" warning on tied or tainted variables that are strings. =item * -C<(s)printf>'s %n formatting code - -The %n formatting code, which causes the number of characters to be -assigned to the next argument to C<printf> or C<sprintf> now actually -assigns the number of characters, instead of the number of bytes. - -It also works now with special lvalue functions like C<substr> and with -nonexistent hash and array elements [perl #3471, #103492]. +Localising a tied scalar that returns a typeglob no longer stops it from +being tied till the end of the scope. =item * -Typeglobs and threads - -Typeglobs returned from threads are no longer cloned if the parent thread -already has a glob with the same name. This means that returned -subroutines will now assign to the right package variables [perl #107366]. +Attempting to C<goto> out of a tied handle method used to cause memory +corruption or crashes. Now it produces an error message instead +[perl #8611]. =item * -C<local $_> - -In Perl 5.14, C<local $_> was changed to create a new variable not tied to -anything, even if $_ was tied before that. But, due to an oversight, it -would still call FETCH once on a tied $_ before replacing it with the new -variable. This has been fixed [perl #105912]. +A bug has been fixed that occurs when a tied variable is used as a +subroutine reference: if the last thing assigned to or returned from the +variable was a reference or typeglob, the C<\&$tied> could either crash or +return the wrong subroutine. The reference case is a regression introduced +in Perl 5.10.0. For typeglobs, it has probably never worked till now. -=item * +=back -Returning tied variables +=head2 "Uninitialized" warnings -When returning a value from a non-lvalue subroutine, Perl copies the value. -Sometimes it cheats for the sake of speed, and does not copy the value if -it makes no observable difference. This optimisation was erroneously -allowing the copy to be skipped on tied variables, causing a difference in -behaviour depending on the tied variable's reference count. This has been -fixed [perl #95548]. +=over =item * -C<utf8::decode> now refuses to modify read-only scalars [perl #91850]. +Various functions that take a filehandle argument in rvalue context +(C<close>, C<readline>, etc.) used to warn twice for an undefined handle +[perl #97482]. =item * -C<dbmopen> with undefined mode - C<dbmopen> now only warns once, rather than three times, if the mode argument is C<undef> [perl #90064]. =item * -DELETE on scalar ties - -Tying an element of %ENV or C<%^H> and then deleting that element would -result in a call to the tie object's DELETE method, even though tying the -element itself is supposed to be equivalent to tying a scalar (the element -is, of course, a scalar) [perl #67490]. - -=item * - -Freeing $_ inside C<grep> or C<map> - -Freeing $_ inside a C<grep> or C<map> block or a code block embedded in a -regular expression used to result in double frees [perl #92254, #92256]. - -=item * - -Warnings with C<+=> - The C<+=> operator does not usually warn when the left-hand side is C<undef>, but it was doing so for tied variables. This has been fixed [perl #44895]. =item * -Tying and autovivification - -When Perl autovivifies an element of a tied array or hash (which entails -calling STORE with a new reference), it now calls FETCH immediately after -the STORE, instead of assuming that FETCH would have returned the same -reference. This can make it easier to implement tied objects [perl #35865, #43011]. +A bug fix in Perl 5.14 introduced a new bug, causing "uninitialized" +warnings to report the wrong variable if the operator in question had +two operands and one was C<%{...}> or C<@{...}>. This has been fixed +[perl #103766]. =item * -C<@&> and C<$&> +C<..> and C<...> in list context now mention the name of the variable in +"uninitialized" warnings for string (as opposed to numeric) ranges. -Mentioning a variable named "&" other than C<$&> (i.e., C<@&> or C<%&>) no -longer stops C<$&> from working. The same applies to variables named "'" -and "`" [perl #24237]. +=back -=item * +=head2 Last-accessed filehandle -Bitwise assignment operators and copy-on-write +Perl has an internal variable that stores the last filehandle to be +accessed. It is used by C<$.> and by C<tell> and C<eof> without +arguments. -In 5.14.0, the bitwise assignment operators C<|=>, C<^=> and C<&=> started -leaving the left-hand side undefined if it happened to be a copy-on-write -string. This has been fixed [perl #108480]. +=over =item * -Three problematic Unicode characters now work better in regex pattern matching under C</i> +It used to be possible to set this internal variable to a glob copy and +then modify that glob copy to be something other than a glob, and still +have the last-accessed filehandle associated with the variable after +assigning a glob to it again: -In the past, three Unicode characters: -LATIN SMALL LETTER SHARP S, -GREEK SMALL LETTER IOTA WITH DIALYTIKA AND TONOS, -and -GREEK SMALL LETTER UPSILON WITH DIALYTIKA AND TONOS, -along with the sequences that they fold to -(including "ss" in the case of LATIN SMALL LETTER SHARP S), -did not properly match under C</i>. 5.14.0 fixed some of these cases, -but introduced others, including a panic when one of the characters or -sequences was used in the C<(?(DEFINE)> regular expression predicate. -The known bugs that were introduced in 5.14 have now been fixed; as well -as some other edge cases that have never worked until now. All these -involve using the characters and sequences outside bracketed character -classes under C</i>. This closes [perl #98546]. + my $foo = *STDOUT; # $foo is a glob copy + <$foo>; # $foo is now the last-accessed handle + $foo = 3; # no longer a glob + $foo = *STDERR; # still the last-accessed handle -There remain known problems when using certain characters with -multi-character folds inside bracketed character classes, including such -constructs as C<qr/[\N{LATIN SMALL LETTER SHARP}a-z]/i>. These -remaining bugs are addressed in [perl #89774]. +Now the C<$foo = 3> assignment unsets that internal variable, so there +is no last-accessed filehandle, just as if C<< <$foo> >> had never +happened. + +This also prevents some unrelated handle from becoming the last-accessed +handle if $foo falls out of scope and the same internal SV gets used for +another handle [perl #97988]. =item * -RT #78266: The regex engine has been leaking memory when accessing -named captures that weren't matched as part of a regex ever since 5.10 -when they were introduced, e.g. this would consume over a hundred MB of -memory: +A regression in 5.14 caused these statements not to set that internal +variable: - for (1..10_000_000) { - if ("foo" =~ /(foo|(?<capture>bar))?/) { - my $capture = $+{capture} - } - } - system "ps -o rss $$"' + my $fh = *STDOUT; + tell $fh; + eof $fh; + seek $fh, 0,0; + tell *$fh; + eof *$fh; + seek *$fh, 0,0; + readline *$fh; -=item * +This is now fixed, but C<tell *{ *$fh }> still has the problem, and it +is not clear how to fix it [perl #106536]. -A constant subroutine assigned to a glob whose name contains a null -will no longer cause extra globs to pop into existence when the -constant is referenced under its new name. +=back -=item * +=head2 Redefinition warnings -C<sort> was not treating C<sub {}> and C<sub {()}> as equivalent when -such a sub was provided as the comparison routine. It used to croak on -C<sub {()}>. +=over =item * @@ -3879,155 +3812,114 @@ sub foo(){u} sub foo(){v} -=item * - -A bug fix in Perl 5.14 introduced a new bug, causing "uninitialized" -warnings to report the wrong variable if the operator in question had -two operands and one was C<%{...}> or C<@{...}>. This has been fixed -[perl #103766]. +=back -=item * +=head2 Overloading -C<< version->new("version") >> and C<printf "%vd", "version"> no longer -crash [perl #102586]. +=over =item * -C<$tied =~ y/a/b/>, C<chop $tied> and C<chomp $tied> now call FETCH -just once when $tied holds a reference. +Arithmetic assignment (C<$left += $right>) involving overloaded objects +that rely on the 'nomethod' override no longer segfault when the left +operand is not overloaded. =item * -Four-argument C<select> now always calls FETCH on tied arguments. It -used to skip the call if the tied argument happened to hold C<undef> or -a typeglob. +Errors that occur when methods cannot be found during overloading now +mention the correct package name, as they did in 5.8.x, instead of +erroneously mentioning the "overload" package, as they have since 5.10.0. =item * -Four-argument C<select> no longer produces its "Non-string passed as -bitmask" warning on tied or tainted variables that are strings. - -=item * +Undefining C<%overload::> no longer causes a crash. -C<sysread> now always calls FETCH on the buffer passed to it if the -buffer is tied. It used to skip the call if the tied variable happened -to hold a typeglob. +=back -=item * +=head2 Fixes to the C<sort> operator -C<< $tied .= <> >> now calls FETCH once on C<$tied>. It used to call -it multiple times if the last value assigned to or returned from the -tied variable was anything other than a string or typeglob. +=over =item * -Return value of C<eval> - -C<eval> returns C<undef> in scalar context or an empty list in list -context when there is a run-time error. When C<eval> was passed a -string in list context and a syntax error occurred, it used to return a -list containing a single undefined element. Now it returns an empty -list in list context for all errors [perl #80630]. +C<sort> was not treating C<sub {}> and C<sub {()}> as equivalent when +such a sub was provided as the comparison routine. It used to croak on +C<sub {()}>. =item * -C<goto &func> no longer crashes, but produces an error message, when -the unwinding of the current subroutine's scope fires a destructor that -undefines the subroutine being "goneto" [perl #99850]. +C<sort> now works once more with custom sort routines that are XSUBs. It +stopped working in 5.10.0. =item * -Arithmetic assignment (C<$left += $right>) involving overloaded objects -that rely on the 'nomethod' override no longer segfault when the left -operand is not overloaded. +C<sort> with a constant for a custom sort routine, although it produces +unsorted results, no longer crashes. It started crashing in 5.10.0. =item * -Assigning C<__PACKAGE__> or any other shared hash key scalar to a stash -element no longer causes a double free. Regardless of this change, the -results of such assignments are still undefined. +Warnings emitted by C<sort> when a custom comparison routine returns a +non-numeric value now contain "in sort" and show the line number of the +C<sort> operator, rather than the last line of the comparison routine. The +warnings also occur now only if warnings are enabled in the scope where +C<sort> occurs. Previously the warnings would occur if enabled in the +comparison routine's scope. =item * -Assigning C<__PACKAGE__> or another shared hash key string to a -variable no longer stops that variable from being tied if it happens to -be a PVMG or PVLV internally. - -=item * +C<< sort { $a <=> $b } >>, which is optimised internally, now produces +"uninitialized" warnings for NaNs (not-a-number values), since C<< <=> >> +returns C<undef> for those. This brings it in line with +S<C<< sort { 1; $a <=> $b } >>> and other more complex cases, which are not +optimised [perl #94390]. -Creating a C<UNIVERSAL::AUTOLOAD> sub no longer stops C<%+>, C<%-> and -C<%!> from working some of the time [perl #105024]. +=back -=item * +=head2 Fixes affecting the debugger -When presented with malformed UTF-8 input, the XS-callable functions -C<is_utf8_string()>, C<is_utf8_string_loc()>, and -C<is_utf8_string_loclen()> could read beyond the end of the input -string by up to 12 bytes. This no longer happens. [perl #32080]. -However, currently, C<is_utf8_char()> still has this defect, see -L</is_utf8_char()> above. +=over =item * -Doing a substitution on a tied variable returning a copy-on-write -scalar used to cause an assertion failure or an "Attempt to free -nonexistent shared string" warning. +F<dumpvar.pl>, and consequently the C<x> command in the debugger, have been +fixed to handle objects blessed into classes whose names contain "=". The +contents of such objects used not to be dumped [perl #101814]. =item * -The debugger no longer tries to do C<local $_> when dumping data -structures. +The "R" command for restarting a debugger session has been fixed to work on +Windows, or any other system lacking a C<POSIX::_SC_OPEN_MAX> constant +[perl #87740]. =item * -Calling C<readline($fh)> where $fh is a glob copy (e.g., after C<$fh = -*STDOUT>), assigning something other than a glob to $fh, and then -freeing $fh (e.g., by leaving the scope where it is defined) no longer -causes the internal variable used by C<$.> (C<PL_last_in_gv>) to point -to a freed scalar, that could be reused for some other glob, causing -C<$.> to use some unrelated filehandle [perl #97988]. +The C<#line 42 foo> directive used not to update the arrays of lines used +by the debugger if it occurred in a string eval. This was partially fixed +in 5.14, but it only worked for a single C<#line 42 foo> in each eval. Now +it works for multiple. =item * -A regression in 5.14 caused these statements not to set the internal -variable that holds the handle used by C<$.>: - - my $fh = *STDOUT; - tell $fh; - eof $fh; - seek $fh, 0,0; - tell *$fh; - eof *$fh; - seek *$fh, 0,0; - readline *$fh; - -This is now fixed, but C<tell *{ *$fh }> still has the problem, and it -is not clear how to fix it [perl #106536]. +When subroutine calls are intercepted by the debugger, the name of the +subroutine or a reference to it is stored in C<$DB::sub>, for the debugger +to access. In some cases (such as C<$foo = *bar; undef *bar; &$foo>) +C<$DB::sub> would be set to a name that could not be used to find the +subroutine, and so the debugger's attempt to call it would fail. Now the +check to see whether a reference is needed is more robust, so those +problems should not happen anymore [rt.cpan.org #69862]. =item * -Version comparisons, such as those that happen implicitly with C<use -v5.43>, no longer cause locale settings to change [perl #105784]. +Every subroutine has a filename associated with it that the debugger uses. +The one associated with constant subroutines used to be misallocated when +cloned under threads. Consequently, debugging threaded applications could +result in memory corruption [perl #96126]. -=item * +=back -Perl now holds an extra reference count on the package that code is -currently compiling in. This means that the following code no longer crashes [perl #101486]: +=head2 Fixes to the C<glob> operator - package Foo; - BEGIN {*Foo:: = *Bar::} - sub foo; - -=item * - -F<dumpvar.pl>, and consequently the C<x> command in the debugger, have been -fixed to handle objects blessed into classes whose names contain "=". The -contents of such objects used not to be dumped [perl #101814]. - -=item * - -The C<x> repetition operator no longer crashes on 64-bit builds with large -repeat counts [perl #94560]. +=over =item * @@ -4050,364 +3942,444 @@ =item * -In 5.14, C</[[:lower:]]/i> and C</[[:upper:]]/i> no longer matched the -opposite case. This has been fixed [perl #101970]. +Under miniperl (used to configure modules when perl itself is built), +C<glob> now clears %ENV before calling csh, since the latter croaks on some +systems if it does not like the contents of the LS_COLORS enviroment +variable [perl #98662]. + +=back + +=head2 Prototypes of built-in keywords + +=over =item * -A regular expression match with an overloaded object on the right-hand side -would in some cases stringify the object too many times. +The C<prototype> function no longer dies for the C<__FILE__>, C<__LINE__> +and C<__PACKAGE__> directives. It now returns an empty-string prototype +for them, because they are syntactically indistinguishable from nullary +functions like C<time>. =item * -The C-level C<pregcomp> function could become confused as to whether the -pattern was in UTF8 if the pattern was an overloaded, tied, or otherwise -magical scalar [perl #101940]. +C<prototype> now returns C<undef> for all overridable infix operators, +such as C<eq>, which are not callable in any way resembling functions. +It used to return incorrect prototypes for some and die for others +[perl #94984]. =item * -A regression has been fixed that was introduced in 5.14, in C</i> -regular expression matching, in which a match improperly fails if the -pattern is in UTF-8, the target string is not, and a Latin-1 character -precedes a character in the string that should match the pattern. -[perl #101710] +The prototypes of several built-in functions--C<getprotobynumber>, C<lock>, +C<not> and C<select>--have been corrected, or at least are now closer to +reality than before. + +=back + +=head2 Bugs involving the dereferencing operators + +=over =item * -The C<#line 42 foo> directive used not to update the arrays of lines used -by the debugger if it occurred in a string eval. This was partially fixed -in 5.14, but it only worked for a single C<#line 42 foo> in each eval. Now -it works for multiple. +C<defined(${"..."})>, C<defined(*{"..."})>, etc., used to +return true for most, but not all built-in variables, if +they had not been used yet. This bug affected C<${^GLOBAL_PHASE}> and +C<${^UTF8CACHE}>, among others. It also used to return false if the +package name was given as well (C<${"::!"}>) [perl #97978, #97492]. =item * -When subroutine calls are intercepted by the debugger, the name of the -subroutine or a reference to it is stored in C<$DB::sub>, for the debugger -to access. In some cases (such as C<$foo = *bar; undef *bar; &$foo>) -C<$DB::sub> would be set to a name that could not be used to find the -subroutine, and so the debugger's attempt to call it would fail. Now the -check to see whether a reference is needed is more robust, so those -problems should not happen anymore [rt.cpan.org #69862]. +Perl 5.10.0 introduced a similar bug: C<defined(*{"foo"})> where "foo" +represents the name of a built-in global variable used to return false if +the variable had never been used before, but only on the I<first> call. +This, too, has been fixed. =item * -Localising a tied scalar that returns a typeglob no longer stops it from -being tied till the end of the scope. +Since 5.6.0, C<*{ ... }> has been inconsistent in how it treats undefined +values. It would die in strict mode or lvalue context for most undefined +values, but would be treated as the empty string (with a warning) for the +specific scalar return by C<undef()> (C<&PL_sv_undef> internally). This +has been corrected. C<undef()> is now treated like other undefined +scalars, as in Perl 5.005. + +=back + +=head2 Threading bugs + +=over =item * -When C<open> is called with three arguments, the third being a file handle -(as in C<< open $fh, ">&", $fh2 >>), if the third argument is tied or a -reference to a tied variable, FETCH is now called exactly once, instead of -0, 2, or 3 times (all of which could occur in various circumstances). +Typeglobs returned from threads are no longer cloned if the parent thread +already has a glob with the same name. This means that returned +subroutines will now assign to the right package variables [perl #107366]. =item * -C<sort> no longer ignores FETCH when passed a reference to a tied glob for -the comparison routine. +Some cases of threads crashing due to memory allocation during cloning have +been fixed [perl #90006]. =item * -Warnings emitted by C<sort> when a custom comparison routine returns a -non-numeric value now show the line number of the C<sort> operator, rather -than the last line of the comparison routine. The warnings also occur now -only if warnings are enabled in the scope where C<sort> occurs. Previously -the warnings would occur if enabled in the comparison routine's scope. +Thread joining would sometimes emit "Attempt to free unreferenced scalar" +warnings if C<caller> had been used from the C<DB> package prior to thread +creation [perl #98092]. =item * -C<Internals::SvREFCNT> now behaves consistently in 'get' and 'set' scenarios -[perl #103222] and also treats the reference count as unsigned. +Locking a subroutine (via C<lock &sub>) is no longer a compile-time error +for regular subs. For lvalue subroutines, it no longer tries to return the +sub as a scalar, resulting in strange side effects like C<ref \$_> +returning "CODE" in some instances. + +C<lock &sub> is now a run-time error if L<threads::shared> is loaded (a +no-op otherwise), but that may be rectified in a future version. + +=back + +=head2 Fixes to C<given> and C<when> + +=over =item * -Calling C<require> on an implicit C<$_> when C<*CORE::GLOBAL::require> has -been overridden does not segfault anymore, and C<$_> is now passed to the -overriding subroutine [perl #78260]. +C<given> was not scoping its implicit $_ properly, resulting in memory +leaks or "Variable is not available" warnings [perl #94682]. =item * -In Perl 5.14.0, C<$tainted ~~ @array> stopped working properly. Sometimes -it would erroneously fail (when C<$tainted> contained a string that occurs -in the array I<after> the first element) or erroneously succeed (when -C<undef> occurred after the first element) [perl #93590]. +C<given> was not calling set-magic on the implicit lexical C<$_> that it +uses. This meant, for example, that C<pos> would be remembered from one +execution of the same C<given> block to the next, even if the input were a +different variable [perl #84526]. =item * -C<use> and C<require> are no longer affected by the I/O layers active in -the caller's scope (enabled by L<open.pm|open>) [perl #96008]. +C<when> blocks are now capable of returning variables declared inside the +enclosing C<given> block [perl #93548]. + +=back + +=head2 Fixes to the C<substr> operator + +=over =item * -Errors that occur when methods cannot be found during overloading now -mention the correct package name, as they did in 5.8.x, instead of -erroneously mentioning the "overload" package, as they have since 5.10.0. +Tied (and otherwise magical) variables are no longer exempt from the +"Attempt to use reference as lvalue in substr" warning. =item * -Undefining C<%overload::> no longer causes a crash. +That warning now occurs when the returned lvalue is assigned to, not +when C<substr> itself is called. This only makes a difference if the +return value of C<substr> is referenced and assigned to later. =item * -C<our $::辿; $辿> (which is invalid) no longer produces the "Compilation -error at lib/utf8_heavy.pl..." error message, which it started emitting in -5.10.0 [perl #99984]. +Passing a substring of a read-only value or a typeglob to a function +(potential lvalue context) no longer causes an immediate "Can't coerce" +or "Modification of a read-only value" error. That error only occurs +if and when the value passed is assigned to. + +The same thing happens with the "substr outside of string" error. If +the lvalue is only read, not written to, it is now just a warning, as +with rvalue C<substr>. =item * -In case-insensitive regular expression pattern matching, no longer on -UTF-8 encoded strings does the scan for the start of match only look at -the first possible position. This caused matches such as -C<"f\x{FB00}" =~ /ff/i> to fail. +C<substr> assignments no longer call FETCH twice if the first argument +is a tied variable, just once. + +=back + +=head2 Fixes affecting the C API + +=over =item * -On 64-bit systems, C<read()> now understands large string offsets beyond -the 32-bit range. +The C<newHVhv> XS function now works on tied hashes, instead of crashing or +returning an empty hash. =item * -Errors that occur when processing subroutine attributes no longer cause the -subroutine's op tree to leak. +The C<SvIsCOW> C macro now returns false for read-only copies of typeglobs, +such as those created by: + + $hash{elem} = *foo; + Hash::Util::lock_value %hash, 'elem'; + +It used to return true. =item * -C<sort> now works once more with custom sort routines that are XSUBs. It -stopped working in 5.10.0. +The C<SvPVutf8> C function no longer tries to modify its argument, +resulting in errors [perl #108994]. =item * -C<sort> with a constant for a custom sort routine, although it produces -unsorted results, no longer crashes. It started crashing in 5.10.0. +C<SvPVutf8> now works properly with magical variables. =item * -Warnings produced when a custom sort routine returns a non-numeric value -now contain "in sort"; e.g., "Use of uninitialized value in sort". +C<SvPVbyte> now works properly non-PVs. =item * -C<< sort { $a <=> $b } >>, which is optimised internally, now produces -"uninitialized" warnings for NaNs (not-a-number values), since C<< <=> >> -returns C<undef> for those. This brings it in line with -S<C<< sort { 1; $a <=> $b } >>> and other more complex cases, which are not -optimised [perl #94390]. +When presented with malformed UTF-8 input, the XS-callable functions +C<is_utf8_string()>, C<is_utf8_string_loc()>, and +C<is_utf8_string_loclen()> could read beyond the end of the input +string by up to 12 bytes. This no longer happens. [perl #32080]. +However, currently, C<is_utf8_char()> still has this defect, see +L</is_utf8_char()> above. =item * -C<..> and C<...> in list context now call FETCH only once on tied -arguments, instead of three or four times [perl #53554]. +The C-level C<pregcomp> function could become confused as to whether the +pattern was in UTF8 if the pattern was an overloaded, tied, or otherwise +magical scalar [perl #101940]. + +=back + +=head2 Other notable fixes + +=over =item * -C<..> and C<...> in list context now mention the name of the variable in -"uninitialized" warnings for string (as opposed to numeric) ranges. +C<~~> now correctly handles the precedence of Any~~Object, and is not tricked +by an overloaded object on the left-hand side. =item * -Passing the same constant subroutine to both C<index> and C<formline> no -longer causes one or the other to fail [perl #89218]. (5.14.1) +C<quotemeta> now quotes consistently the same non-ASCII characters under +C<use feature 'unicode_strings'>, regardless of whether the string is +encoded in UTF-8 or not, hence fixing the last vestiges (we hope) of the +infamous L<perlunicode/The "Unicode Bug">. [perl #77654]. + +Which of these code points is quoted has changed, based on Unicode's +recommendations. See L<perlfunc/quotemeta> for details. =item * -List assignment to lexical variables declared with attributes in the same -statement (C<my ($x, @ y) : blimp = (72,94)>) stopped working in Perl 5.8.0. -It has now been fixed. +No warning for C<open(foo::bar)> + +When one writes C<open foo || die>, which used to work in Perl 4, a +"Precedence problem" warning is produced. This warning used erroneously to +apply to fully-qualified bareword handle names not followed by C<||>. This +has been corrected. =item * -Perl 5.10.0 introduced some faulty logic that made "U*" in the middle of -a pack template equivalent to "U0" if the input string was empty. This has -been fixed [perl #90160]. +C<select> and package aliasing + +After package aliasing (C<*foo:: = *bar::>), C<select> with 0 or 1 argument +would sometimes return a name that could not be used to refer to the +filehandle, or sometimes it would return C<undef> even when a filehandle +was selected. Now it returns a typeglob reference in such cases. =item * -Destructors on objects were not called during global destruction on objects -that were not referenced by any scalars. This could happen if an array -element were blessed (e.g., C<bless \$a[0]>) or if a closure referenced a -blessed variable (C<bless \my @a; sub foo { @a }>). +C<PerlIO::get_layers> and numbers -Now there is an extra pass during global destruction to fire destructors on -any objects that might be left after the usual passes that check for -objects referenced by scalars [perl #36347]. +C<PerlIO::get_layers> no longer ignores some arguments that it thinks are +numeric, while treating others as filehandle names. It is now consistent +for flat scalars (i.e., not references). -This bug fix was added in Perl 5.13.9, but caused problems with some CPAN -modules that were relying on the bug. Since it was so close to Perl -5.14.0, the fix was reverted in 5.13.10, to allow more time for the modules -to adapt. Hopefully they will be fixed soon (see L</Known Problems>, -below). +=item * + +Unrecognised switches on C<#!> line + +If a switch, such as B<-x>, that cannot occur on the C<#!> line is used +there, perl dies with "Can't emulate...". + +It used to produce the same message for switches that perl did not +recognise at all, whether on the command line or the C<#!> line. + +Now it produces the "Unrecognized switch" error message [perl #104288]. =item * -C<given> was not calling set-magic on the implicit lexical C<$_> that it -uses. This meant, for example, that C<pos> would be remembered from one -execution of the same C<given> block to the next, even if the input were a -different variable [perl #84526]. +C<system> and SIGCHLD + +C<system> now temporarily blocks the SIGCHLD signal handler, to prevent the +signal handler from stealing the exit status [perl #105700]. =item * -The "R" command for restarting a debugger session has been fixed to work on -Windows, or any other system lacking a C<POSIX::_SC_OPEN_MAX> constant -[perl #87740]. +C<(s)printf>'s %n formatting code + +The %n formatting code, which causes the number of characters to be +assigned to the next argument to C<printf> or C<sprintf> now actually +assigns the number of characters, instead of the number of bytes. + +It also works now with special lvalue functions like C<substr> and with +nonexistent hash and array elements [perl #3471, #103492]. =item * -Fixed a case where it was possible that a freed buffer may have been read -from when parsing a here document [perl #90128]. (5.14.1) +C<local $_> + +In Perl 5.14, C<local $_> was changed to create a new variable not tied to +anything, even if $_ was tied before that. But, due to an oversight, it +would still call FETCH once on a tied $_ before replacing it with the new +variable. This has been fixed [perl #105912]. =item * -The C<study> function could become confused if fed a string longer than -2**31 characters. Now that it's a no-op, it can't. - -=item * +Perl skips copying values returned from a subroutine, for the sake of +speed, if doing so would make no observable difference. Due to faulty +logic, this would happen with the +result of C<delete>, C<shift> or C<splice>, even if the result was +referenced elsewhere. It also did so with tied variables about to be freed +[perl #91844, #95548]. -C<each(I<ARRAY>)> is now wrapped in C<defined(...)>, like C<each(I<HASH>)>, -inside a C<while> condition [perl #90888]. =item * -In @INC filters (subroutines returned by subroutines in @INC), $_ used to -misbehave: If returned from a subroutine, it would not be copied, but the -variable itself would be returned; and freeing $_ (e.g., with C<undef *_>) -would cause perl to crash. This has been fixed [perl #91880]. +C<utf8::decode> now refuses to modify read-only scalars [perl #91850]. =item * -An ASCII single quote (') in a symbol name is meant to be equivalent to a -double colon (::) except at the end of the name. It was not equivalent if -followed by a null character, but now it is [perl #88138]. +Freeing $_ inside a C<grep> or C<map> block, a code block embedded in a +regular expression, or an @INC filter (a subroutine returned by a +subroutine in @INC) used to result in double frees or crashes +[perl #91880, #92254, #92256]. =item * -The abbreviations for four C1 control characters C<MW> C<PM>, C<RI>, and -C<ST> were previously unrecognized by C<\N{}>, vianame(), and -string_vianame(). +C<@&> and C<$&> + +Mentioning a variable named "&" other than C<$&> (i.e., C<@&> or C<%&>) no +longer stops C<$&> from working. The same applies to variables named "'" +and "`" [perl #24237]. =item * -Some cases of threads crashing due to memory allocation during cloning have -been fixed [perl #90006]. +Return value of C<eval> + +C<eval> returns C<undef> in scalar context or an empty list in list +context when there is a run-time error. When C<eval> was passed a +string in list context and a syntax error occurred, it used to return a +list containing a single undefined element. Now it returns an empty +list in list context for all errors [perl #80630]. =item * -Attempting to C<goto> out of a tied handle method used to cause memory -corruption or crashes. Now it produces an error message instead -[perl #8611]. +C<goto &func> no longer crashes, but produces an error message, when +the unwinding of the current subroutine's scope fires a destructor that +undefines the subroutine being "goneto" [perl #99850]. =item * -Perl skips copying values returned from a subroutine if it thinks the value -is not in use elsewhere. Due to faulty logic, this would happen with the -result of C<delete>, C<shift> or C<splice>, even if the result was -referenced elsewhere. So C<< \sub { delete $_[0] }->($x) >> would return a -reference to C<$x>. This has been fixed [perl #91844]. +Creating a C<UNIVERSAL::AUTOLOAD> sub no longer stops C<%+>, C<%-> and +C<%!> from working some of the time [perl #105024]. =item * -The C<prototype> function no longer dies for the C<__FILE__>, C<__LINE__> -and C<__PACKAGE__> directives. It now returns an empty-string prototype -for them, because they are syntactically very similar to nullary functions -like C<time>. +Perl now holds an extra reference count on the package that code is +currently compiling in. This means that the following code no longer crashes [perl #101486]: + + package Foo; + BEGIN {*Foo:: = *Bar::} + sub foo; =item * -C<prototype> now returns C<undef> for all overridable infix operators, -such as C<eq>, which are not callable in any way resembling functions. -It used to return incorrect prototypes for some and die for others -[perl #94984]. +The C<x> repetition operator no longer crashes on 64-bit builds with large +repeat counts [perl #94560]. =item * -Some core bugs affecting L<Hash::Util> have been fixed: locking a hash -element that is a glob copy no longer causes subsequent assignment to it to -corrupt the glob, and unlocking a hash element that holds a copy-on-write -scalar no longer causes modifications to that scalar to modify other -scalars that were sharing the same string buffer. +Calling C<require> on an implicit C<$_> when C<*CORE::GLOBAL::require> has +been overridden does not segfault anymore, and C<$_> is now passed to the +overriding subroutine [perl #78260]. =item * -C<when> blocks are now capable of returning variables declared inside the -enclosing C<given> block [perl #93548]. +In Perl 5.14.0, C<$tainted ~~ @array> stopped working properly. Sometimes +it would erroneously fail (when C<$tainted> contained a string that occurs +in the array I<after> the first element) or erroneously succeed (when +C<undef> occurred after the first element) [perl #93590]. =item * -A problem with context propagation when a C<do> block is an argument to -C<return> has been fixed. It used to cause C<undef> to be returned in -some cases of a C<return> inside an C<if> block which itself is followed by -another C<return>. +C<use> and C<require> are no longer affected by the I/O layers active in +the caller's scope (enabled by L<open.pm|open>) [perl #96008]. =item * -Calling C<index> with a tainted constant no longer causes constants in -subsequently compiled code to become tainted [perl #64804]. +C<our $::辿; $辿> (which is invalid) no longer produces the "Compilation +error at lib/utf8_heavy.pl..." error message, which it started emitting in +5.10.0 [perl #99984]. =item * -Use of lexical (C<my>) variables in code blocks embedded in regular -expressions will no longer result in memory corruption or crashes. - -Nevertheless, these code blocks are still experimental, as there are still -problems with the wrong variables being closed over (in loops for instance) -and with abnormal exiting (e.g., C<die>) causing memory corruption. +On 64-bit systems, C<read()> now understands large string offsets beyond +the 32-bit range. =item * -The C<SvIsCOW> C macro now returns false for read-only copies of typeglobs, -such as those created by: +Errors that occur when processing subroutine attributes no longer cause the +subroutine's op tree to leak. - $hash{elem} = *foo; - Hash::Util::lock_value %hash, 'elem'; +=item * -It used to return true. +Passing the same constant subroutine to both C<index> and C<formline> no +longer causes one or the other to fail [perl #89218]. (5.14.1) =item * -Assignment to C<$^A> (the format output accumulator) now recalculates -the number of lines output. +List assignment to lexical variables declared with attributes in the same +statement (C<my ($x, @ y) : blimp = (72,94)>) stopped working in Perl 5.8.0. +It has now been fixed. =item * -The regexp optimiser no longer crashes on debugging builds when merging -fixed-string nodes with inconvenient contents. +Perl 5.10.0 introduced some faulty logic that made "U*" in the middle of +a pack template equivalent to "U0" if the input string was empty. This has +been fixed [perl #90160]. =item * -Locking a subroutine (via C<lock &sub>) is no longer a compile-time error -for regular subs. For lvalue subroutines, it no longer tries to return the -sub as a scalar, resulting in strange side effects like C<ref \$_> -returning "CODE" in some instances. +Destructors on objects were not called during global destruction on objects +that were not referenced by any scalars. This could happen if an array +element were blessed (e.g., C<bless \$a[0]>) or if a closure referenced a +blessed variable (C<bless \my @a; sub foo { @a }>). -C<lock &sub> is now a run-time error if L<threads::shared> is loaded (a -no-op otherwise), but that may be rectified in a future version. +Now there is an extra pass during global destruction to fire destructors on +any objects that might be left after the usual passes that check for +objects referenced by scalars [perl #36347]. + +This bug fix was added in Perl 5.13.9, but caused problems with some CPAN +modules that were relying on the bug. Since it was so close to Perl +5.14.0, the fix was reverted in 5.13.10, to allow more time for the modules +to adapt. Hopefully they will be fixed soon (see L</Known Problems>, +below). =item * -The prototypes of several built-in functions--C<getprotobynumber>, C<lock>, -C<not> and C<select>--have been corrected, or at least are now closer to -reality than before. +Fixed a case where it was possible that a freed buffer may have been read +from when parsing a here document [perl #90128]. (5.14.1) =item * -Most dereferencing operators (C<${}>, etc.) used to call C<FETCH> twice on -a tied operand when doing a symbolic dereference (looking up a variable by -name, which is not permitted under C<use strict 'refs'>). Only C<&{}> did -not have this problem. This has been fixed. +C<each(I<ARRAY>)> is now wrapped in C<defined(...)>, like C<each(I<HASH>)>, +inside a C<while> condition [perl #90888]. =item * -A panic involving the combination of the regular expression modifiers -C</aa> and the C<\b> escape sequence introduced in 5.14.0 has been -fixed [perl #95964]. +A problem with context propagation when a C<do> block is an argument to +C<return> has been fixed. It used to cause C<undef> to be returned in +some cases of a C<return> inside an C<if> block which itself is followed by +another C<return>. =item * -The combination of the regular expression modifiers C</aa> and the C<\b> -and C<\B> escape sequences did not work properly on UTF-8 encoded -strings. All non-ASCII characters under C</aa> should be treated as -non-word characters, but what was happening was that Unicode rules were -used to determine wordness/non-wordness for non-ASCII characters. This -is now fixed [perl #95968]. +Calling C<index> with a tainted constant no longer causes constants in +subsequently compiled code to become tainted [perl #64804]. =item * @@ -4416,12 +4388,6 @@ =item * -The C<\h>, C<\H>, C<\v> and C<\V> regular expression metacharacters used to -cause a panic error message when attempting to match at the end of the -string [perl #96354]. - -=item * - For list assignments like C<($a,$b) = ($b,$a)>, Perl has to make a copy of the items on the right-hand side before assignment them to the left. For efficiency's sake, it assigns the values on the right straight to the items @@ -4442,42 +4408,12 @@ =item * -Every subroutine has a filename associated with it, that the debugger uses. -The one associated with constant subroutines used to be misallocated when -cloned under threads. Consequently, debugging threaded applications could -result in memory corruption [perl #96126]. - -=item * - C<caller> no longer leaks memory when called from the DB package if C<@DB::args> was assigned to after the first call to C<caller>. L<Carp> was triggering this bug [perl #97010]. =item * -C<defined(${"..."})>, C<defined(*{"..."})>, etc., used to -return true for most, but not all built-in variables, if -they had not been used yet. Many times that new built-in -variables were added in past versions, this construct was -not taken into account, so this affected C<${^GLOBAL_PHASE}> and -C<${^UTF8CACHE}>, among others. It also used to return false if the -package name was given as well (C<${"::!"}>) [perl #97978, #97492]. - -=item * - -Perl 5.10.0 introduced a similar bug: C<defined(*{"foo"})> where "foo" -represents the name of a built-in global variable used to return false if -the variable had never been used before, but only on the I<first> call. -This, too, has been fixed. - -=item * - -Various functions that take a filehandle argument in rvalue context -(C<close>, C<readline>, etc.) used to call C<FETCH> multiple times, if it -was a tied variable, and warn twice, if it was C<undef> [perl #97482]. - -=item * - C<close> and similar filehandle functions, when called on built-in global variables (like C<$+>), used to die if the variable happened to hold the undefined value, instead of producing the usual "Use of uninitialized @@ -4491,23 +4427,6 @@ =item * -C<defined ${ $tied_variable }> used to call C<FETCH> multiple times, but -now calls it just once. - -=item * - -Some cases of dereferencing a complex expression, such as -C<${ (), $tied } = 1>, used to call C<FETCH> multiple times, but now call -it once. - -=item * - -For a tied variable returning a package name, C<$tied-E<gt>method> used to -call C<FETCH> multiple times (even up to six!), and sometimes would -fail to call the method, due to memory corruption. - -=item * - Calling an undefined anonymous subroutine (e.g., what $x holds after C<undef &{$x = sub{}}>) used to cause a "Not a CODE reference" error, which has been corrected to "Undefined subroutine called" [perl #71154]. @@ -4519,74 +4438,18 @@ =item * -Since 5.6.0, C<*{ ... }> has been inconsistent in how it treats undefined -values. It would die in strict mode or lvalue context for most undefined -values, but would be treated as the empty string (with a warning) for the -specific scalar return by C<undef()> (C<&PL_sv_undef> internally). This -has been corrected. C<undef()> is now treated like other undefined -scalars, as in Perl 5.005. - -=item * - C<setpgrp($foo)> used to be equivalent to C<($foo, setpgrp)>, because C<setpgrp> was ignoring its argument if there was just one. Now it is equivalent to C<setpgrp($foo,0)>. =item * -Assignments like C<*$tied = \&{"..."}> and C<*glob = $tied> now call FETCH -only once. - -=item * - -C<chdir>, C<chmod>, C<chown>, C<utime>, C<truncate>, C<stat>, C<lstat> and -the filetest ops (C<-r>, C<-x>, etc.) now always call FETCH if passed a tied -variable as the last argument. They used to ignore tiedness if the last -thing return from or assigned to the variable was a typeglob or reference -to a typeglob. - -=item * - -If things were arranged in memory the right way, it was possible for -thread joining to emit "Attempt to free unreferenced scalar" warnings if -C<caller> had been used from the C<DB> package prior to thread creation, -due to the way pads were reference-counted and cloned [perl #98092]. - -=item * - -A bug has been fixed that occurs when a tied variable is used as a -subroutine reference: if the last thing assigned to or returned from the -variable was a reference or typeglob, the C<\&$tied> could either crash or -return the wrong subroutine. The reference case is a regression introduced -in Perl 5.10.0. For typeglobs, it has probably never worked till now. - -=item * - -C<given> was not scoping its implicit $_ properly, resulting in memory -leaks or "Variable is not available" warnings [perl #94682]. - -=item * - -C<-l> followed by a bareword no longer "eats" the previous argument to -the list operator in whose argument list it resides. In less convoluted -English: C<print "bar", -l foo> now actually prints "bar", because C<-l> -on longer eats it. - -=item * - C<shmread> was not setting the scalar flags correctly when reading from shared memory, causing the existing cached numeric representation in the scalar to persist [perl #98480]. =item * -Under miniperl (used to configure modules when perl itself is built), -C<glob> now clears %ENV before calling csh, since the latter croaks on some -systems if it does not like the contents of the LS_COLORS enviroment -variable [perl #98662]. - -=item * - C<++> and C<--> now work on copies of globs, instead of dying. =item * @@ -4598,24 +4461,6 @@ =item * -The C<SvPVutf8> C function no longer tries to modify its argument, -resulting in errors [perl #108994]. - -=item * - -C<SvPVutf8> now works properly with magical variables. - -=item * - -C<SvPVbyte> now works properly non-PVs. - -=item * - -Version objects no longer cause memory leaks in boolean context -[perl #109762]. - -=item * - C<< $$ >> is no longer tainted. Since this value comes directly from C<< getpid() >>, it is always safe. @@ -4626,20 +4471,10 @@ =item * -C<< (?foo: ...) >> no longer loses passed in character set. - -=item * - C<< die; >> with a non-reference, non-string, or magical (e.g., tainted) value in $@ now properly propagates that value [perl #111654]. -=item * - -The trie optimisation used to have problems with alternations containing -an empty C<(?:)>, causing C<< "x" =~ /\A(?>(?:(?:)A|B|C?x))\z/ >> not to -match, whereas it should [perl #111842]. - =back =head1 Known Problems