Bug 17442 – regex purity issues

Status
NEW
Severity
normal
Priority
P3
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2017-05-27T07:30:09Z
Last change time
2024-12-01T16:30:15Z
Assigned to
Dmitry Olshansky
Creator
Brad Roberts
Moved to GitHub: phobos#10250 →

Comments

Comment #0 by braddr — 2017-05-27T07:30:09Z
At least two of the functions in std.regex that ought to be usable in a pure context aren't. I suspect there's a broader issue with that subsystem, but haven't investigated. --------- module bugregex; string unifyNewLine(string str) pure { import std.regex; return std.regex.replace(str, regex(`\r\n|\r|\n`, "g"), "\n"); } --------- $ dmd -c -ofbugregex.o bugregex.d bugregex.d(7): Error: pure function 'bugregex.unifyNewLine' cannot call impure function 'std.regex.regex!string.regex' bugregex.d(7): Error: pure function 'bugregex.unifyNewLine' cannot call impure function 'std.regex.replace!(match, string, char, Regex!char).replace'
Comment #1 by uplink.coder — 2017-05-29T02:06:34Z
The reason for this is that regex calls malloc
Comment #2 by braddr — 2017-05-29T02:25:15Z
That's a tiny tip of a much larger iceberg.
Comment #3 by robert.schadek — 2024-12-01T16:30:15Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10250 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB