[Issue 18742] New: std.regex: Using CodePointSet in AAs breaks if reference count changes

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Apr 7 15:11:05 UTC 2018


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

          Issue ID: 18742
           Summary: std.regex: Using CodePointSet in AAs breaks if
                    reference count changes
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Keywords: bootcamp
          Severity: minor
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: johannespfau at gmail.com

When storing a CodePointSet in an AA, the reference count member is included
when hashing, so two identical CodePointSets only differing in the reference
count are not considered as the same AA key. std.regex does actually put
CodePointSets into AAs, so this seems very fragile. As a solution, CodePointSet
should properly implement the toHash function.

Test case:
--------------------------------------
import std.uni, std.stdio;

void main()
{
    int[CodepointSet] aa;
        auto set = unicode.Nd;
    aa[set] = 42;
    writeln(aa[set]);
}
--------------------------------------
This is expected to print 42, but currently throws a RangeError instead.

--


More information about the Digitalmars-d-bugs mailing list