develooper Front page | perl.perl5.porters | Postings from May 2013

[perl #118213] /$qr/p broken under 5.18.0

Dave Mitchell
May 28, 2013 10:46
[perl #118213] /$qr/p broken under 5.18.0
Message ID:
# New Ticket Created by  Dave Mitchell 
# Please include the string:  [perl #118213]
# in the subject line of all future correspondence about this issue. 
# <URL: >

This is a bug report for perl from,
generated with the help of perlbug 1.39 running under perl 5.18.0.

[Please describe your issue here]

This code prints 'a' in 5.16.x, undef in 5.18.0:

    my $pat = qr/a/;
    'aaaa'  =~ /$pat/gp or die;
    print "MATCH=[${^MATCH}]\n";

A bisect shows I broke it:

commit 2c7b5d7698f52b86acffe19a7ec15e85c99337fe
Author: David Mitchell <>
Date:   Thu Jul 26 15:35:39 2012 +0100

    Separate handling of ${^PREMATCH} from $` etc
    Currently the handling of getting the value, length etc of ${^PREMATCH}
    etc is identical to that of $` etc.
    Handle them separately, by adding RX_BUFF_IDX_CARET_PREMATCH etc
    constants to the existing RX_BUFF_IDX_PREMATCH set.
    This allows, when retrieving them, to always return undef if the current
    match didn't use //p. Previously the result depended on stuff such
    as whether the (non-//p) pattern included captures or not.
    The documentation for ${^PREMATCH} etc states that it's only guaranteed to
    return a defined value when the last pattern was //p.
    As well as making things more consistent, this is a necessary
    prerequisite for the following commit, which may not always copy the
    whole string during a non-//p match.

First spotted on perlmonks:

(I intend to work on this ticket)

[Please do not change anything below this line]
Site configuration information for perl 5.18.0:

Configured by davem at Sat May 18 22:48:32 BST 2013.

Summary of my perl5 (revision 5 version 18 subversion 0) configuration:
    osname=linux, osvers=3.8.11-200.fc18.x86_64, archname=x86_64-linux
    uname='linux robin 3.8.11-200.fc18.x86_64 #1 smp wed may 1 19:44:27 utc 2013 x86_64 x86_64 x86_64 gnulinux '
    config_args='-des -Dprefix=/home/davem/perl5/a/perl-5.18.0.out -Uinstallusrbinperl -Doptimize=-g -Accflags=-DDEBUGGING -ggdb'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
    cc='cc', ccflags ='-DDEBUGGING -ggdb -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    cppflags='-DDEBUGGING -ggdb -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.7.2 20121109 (Red Hat 4.7.2-8)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector'

Locally applied patches:

@INC for perl 5.18.0:

Environment for perl 5.18.0:
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PERL_BADLANG (unset)
    SHELL=/bin/bash Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About