www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 17875] New: Range violation in std.regex

https://issues.dlang.org/show_bug.cgi?id=17875

          Issue ID: 17875
           Summary: Range violation in std.regex
           Product: D
           Version: D2
          Hardware: x86
                OS: Windows
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: simen.kjaras gmail.com

import std.regex;
import std.array;
import std.stdio;

unittest {
    auto f = `abc`;
    auto re = `(()|(.+))`;
    writeln(f.matchAll(re)); // Line 8
    writeln(f.matchAll(re).array); // Line 9
}

In the above example, line 9 fails with:

core.exception.RangeError D:\github\phobos\std\regex\package.d(576): Range
violation

Changing the order of line 8 and 9, the problem disappears. Duplicating line 8
causes no exception.

The regex is shortened to the smallest I found that exhibits this behavior.

--
Oct 04