This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Forbid \g0. (tests coming later)
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 3 Jul 2007 14:26:13 +0000 (14:26 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Tue, 3 Jul 2007 14:26:13 +0000 (14:26 +0000)
p4raw-id: //depot/perl@31524

pod/perldiag.pod
regcomp.c

index d0cedfc..338fd12 100644 (file)
@@ -3556,6 +3556,13 @@ Doing so has no effect.
 (W internal) The internal sv_replace() function was handed a new SV with
 a reference count of other than 1.
 
+=item Reference to invalid group 0
+
+(F) You used C<\g0> or similar in a regular expression. You may refer to
+capturing parentheses only with strictly positive integers (normal
+backreferences) or with stricly negative integers (relative
+backreferences), but using 0 does not make sense.
+
 =item Reference to nonexistent group in regex; marked by <-- HERE in m/%s/
 
 (F) You used something like C<\7> in your regular expression, but there are
index 60b31ed..cada4cd 100644 (file)
--- a/regcomp.c
+++ b/regcomp.c
@@ -7052,6 +7052,8 @@ tryagain:
                        goto parse_named_seq;
                }   }
                num = atoi(RExC_parse);
+               if (isg && num == 0)
+                   vFAIL("Reference to invalid group 0");
                 if (isrel) {
                     num = RExC_npar - num;
                     if (num < 1)