develooper Front page | perl.perl5.porters | Postings from January 2019

[perl #133782] length($^R) sometimes wrong

From:
Tony Cook via RT
Date:
January 29, 2019 23:21
Subject:
[perl #133782] length($^R) sometimes wrong
Message ID:
rt-4.0.24-27069-1548804067-73.133782-15-0@perl.org
On Sun, 20 Jan 2019 16:42:12 -0800, tonyc wrote:
> On Sun, 20 Jan 2019 15:09:31 -0800, tonyc wrote:
> > On Sat, 19 Jan 2019 05:45:44 -0800, haukex@zero-g.net wrote:
> > > Hi everyone,
> > >
> > > This oneliner fails, when it most likely shouldn't:
> > >
> > > perl -e 'while( "\N{U+E4}bc" =~ /(..?)(?{$^N})/g )
> > >          { length($^R)==length("$^R") or die }'
> > >
> > > A slightly longer test program (attached) shows that on the second
> > > iteration, length($^R) is reporting 2 instead of the expected 1. It
> > > seems to have something to do with UTF8 strings, since it works fine
> > > on
> > > non-UTF8 strings.
> > >
> > > Tested on several versions of Perl on Linux and Windows (down to
> > > 5.8.9).
> > 
> > From a debugging build:
> > 
> > $ ./perl -e 'while( "\N{U+E4}bc" =~ /(..?)(?{$^N})/g ){
> > length($^R)==length("$^R") or die }'
> > panic: sv_len_utf8 cache 2 real 1 for c at -e line 1.
> > 
> > so I suspect a missing SvSETMAGIC() somewhere.
> 
> which the attached should fix.

Applied as d4c456e337e653ae11876241727b563a684dffe7 with a fix to the ticket number.

Tony

---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=133782



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About