Bug 8349 – CTFE memcpy Error with ctRegex

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-07-05T06:42:00Z
Last change time
2015-06-09T01:31:20Z
Assigned to
nobody
Creator
dsimcha

Comments

Comment #0 by dsimcha — 2012-07-05T06:42:57Z
import std.regex; enum peakRegexStr = r"\>(wgEncode.*Tfbs.*\.(?:narrow)|(?:broad)Peak.gz)</a>"; enum peakRegex = ctRegex!(peakRegexStr); d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1334): Error: memcpy cannot be interpreted at compile time, because it has no available source code d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1431): called from here: move(front(src),front(tgt)) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(1239): called from here: moveAll(this.ir[offset + 1u..__dollar],this.ir[offset..__dollar - 1u]) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(1123): called from here: this.parseQuantifier(fix) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(876): called from here: this.parseRegex() d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6428): called from here: parser.this(pattern,flags) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6412): called from here: regexImpl(pattern,flags) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6437): called from here: regex("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>",[]) d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1334): Error: memcpy cannot be interpreted at compile time, because it has no available source code d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1431): called from here: move(front(src),front(tgt)) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(1239): called from here: moveAll(this.ir[offset + 1u..__dollar],this.ir[offset..__dollar - 1u]) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(1123): called from here: this.parseQuantifier(fix) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(876): called from here: this.parseRegex() d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6428): called from here: parser.this(pattern,flags) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6412): called from here: regexImpl(pattern,flags) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6439): called from here: regex("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>",[]) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6439): called from here: ctGenRegExCode(regex("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>",[])) d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1334): Error: memcpy cannot be interpreted at compile time, because it has no available source code d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1431): called from here: move(front(src),front(tgt)) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(1239): called from here: moveAll(this.ir[offset + 1u..__dollar],this.ir[offset..__dollar - 1u]) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(1123): called from here: this.parseQuantifier(fix) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(876): called from here: this.parseRegex() d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6428): called from here: parser.this(pattern,flags) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6412): called from here: regexImpl(pattern,flags) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6446): called from here: regex("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>",[]) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6446): called from here: StaticRegex(null,Regex(null,null,null,0u,0u,0u,0u,0u,null,null,ShiftOr(null,0u,0u))).this(regex("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>",[]),& func) d:\dmd2\windows\bin\..\..\src\phobos\std\regex.d(6463): Error: template instance std.regex.ctRegexImpl!("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>",[]) error instantiating D:\home\dsimcha\bin\test.d(4): instantiated from here: ctRegex!("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>") D:\home\dsimcha\bin\test.d(4): Error: template instance std.regex.ctRegex!("\\>(wgEncode.*Tfbs.*\\.(?:narrow)|(?:broad)Peak.gz)</a>") error instantiating
Comment #1 by dmitry.olsh — 2012-07-05T06:52:37Z
(In reply to comment #0) > import std.regex; > > enum peakRegexStr = r"\>(wgEncode.*Tfbs.*\.(?:narrow)|(?:broad)Peak.gz)</a>"; > enum peakRegex = ctRegex!(peakRegexStr); > > d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1334): Error: memcpy > cannot be interpreted at compile time, because it has no available source code > d:\dmd2\windows\bin\..\..\src\phobos\std\algorithm.d(1431): called from > here: move(front(src),front(tgt)) Too bad somebody clever enough made std.algorithm.move to use memcpy... and forgot to provide a fallback for CTFE. We'll have these sort of problems till the day we finally replace ALL of C magic with proper D equivalents. In this case array ops should do just fine (if not faster).
Comment #2 by issues.dlang — 2012-07-05T08:41:54Z
As has been pointed out before, we really should start adding unit tests which verify CTFEability. And honestly, I really think that std.algorithm needs better testing anyway. It's actually pretty poorly tested. For instance, one of the major things that I'd like to do with its tests is make sure that all of it works with reference type ranges. I'm pretty sure that the reality of the matter is that a lot of it doesn't.
Comment #3 by verylonglogin.reg — 2012-11-11T23:11:08Z
Comment #4 by dmitry.olsh — 2012-11-30T12:45:28Z
Comment #5 by dmitry.olsh — 2012-12-01T00:15:05Z