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

          Issue ID: 21702
           Summary: avoid quadratic template expansion in constraints of
                    multiple search term versions of
                    std.algorithm.searching.startsWith & endsWith
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: phobos
          Assignee: [email protected]
          Reporter: [email protected]

See DMD issue #21473 for an example of reasonable library usage that takes more
than 22 gigabytes of memory to compile (the process got killed before
finishing). There is other stuff going on too but fixing this problem is enough
to make the example compile.

The culprit is:

---
 uint endsWith(alias pred = "a == b", Range, Needles...)(Range doesThisEnd,
Needles withOneOfThese)
 if (isBidirectionalRange!Range && Needles.length > 1 &&
    is(typeof(.endsWith!pred(doesThisEnd, withOneOfThese[0])) : bool) &&
    is(typeof(.endsWith!pred(doesThisEnd, withOneOfThese[1 .. $])) : uint))
---

Because in certain situations this is causing the compiler to hang I think it
is reasonable to consider this a bug fix rather than an enhancement.

--

Reply via email to