D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 8349 - CTFE memcpy Error with ctRegex
Summary: CTFE memcpy Error with ctRegex
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-07-05 06:42 UTC by David Simcha
Modified: 2015-06-09 01:31 UTC (History)
3 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description David Simcha 2012-07-05 06:42:57 UTC
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 Dmitry Olshansky 2012-07-05 06:52:37 UTC
(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 Jonathan M Davis 2012-07-05 08:41:54 UTC
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 Denis Shelomovskii 2012-11-11 23:11:08 UTC
Fixed in:
https://github.com/D-Programming-Language/phobos/pull/923
Comment 4 Dmitry Olshansky 2012-11-30 12:45:28 UTC
A separate pull for std.regex only:
https://github.com/D-Programming-Language/phobos/pull/984