Comment #0 by n8sh.secondary — 2021-03-12T16:53:50Z
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.
Comment #1 by dlang-bot — 2021-03-12T17:03:57Z
@n8sh created dlang/phobos pull request #7847 "Avoid quadratic template expansion in constraints of multiple search term versions of std.algorithm.searching.startsWith & endsWith" fixing this issue:
- Fix issue #21702 - avoid quadratic template expansion in constraints of multiple search term versions of std.algorithm.searching.startsWith & endsWith
https://github.com/dlang/phobos/pull/7847
Comment #2 by dlang-bot — 2021-03-13T01:25:53Z
dlang/phobos pull request #7847 "Avoid quadratic template expansion in constraints of multiple search term versions of std.algorithm.searching.startsWith & endsWith" was merged into stable:
- 9c7a7750ff7816c7d74f620dc4989b4b92bf904f by Nathan Sashihara:
Fix issue #21702 - avoid quadratic template expansion in constraints of multiple search term versions of std.algorithm.searching.startsWith & endsWith
https://github.com/dlang/phobos/pull/7847
Comment #3 by dlang-bot — 2021-04-25T13:45:59Z
dlang/phobos pull request #7964 "merge stable" was merged into master:
- a23fa4ed06fe188582631bacd6f3405d99855fa6 by Nathan Sashihara:
Fix issue #21702 - avoid quadratic template expansion in constraints of multiple search term versions of std.algorithm.searching.startsWith & endsWith
https://github.com/dlang/phobos/pull/7964
Comment #4 by dlang-bot — 2021-04-27T09:42:39Z
dlang/phobos pull request #8012 "merge stable" was merged into master:
- 6d9a508baf2689d7dcca54f677f8ec9ebdef421b by Nathan Sashihara:
Fix issue #21702 - avoid quadratic template expansion in constraints of multiple search term versions of std.algorithm.searching.startsWith & endsWith
https://github.com/dlang/phobos/pull/8012