[Issue 9634] [CTFE] std.regex.ctRegex chokes on (?:a+)
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sun May 12 13:42:35 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=9634
--- Comment #6 from Dmitry Olshansky <dmitry.olsh at gmail.com> 2013-05-12 13:42:34 PDT ---
(In reply to comment #5)
> Reduced the code from comment #2 further:
>
> struct Bytecode
> {
> int raw;
> }
>
> Bytecode[] getIr()
> {
> Bytecode[] ir;
>
> ir ~= Bytecode(42);
> ir ~= ir[0 .. 1]; // add .dup and CTFE gets it
A-ha! That indicates that the bug is in appending slices of that same array...
That might get us workaround (without dup) and indeed if I change the above
line to this:
foreach(v; ir[0 .. 1])
ir ~= v;
it passes even for bigger slices.
> assert(&ir[0] != &ir[1]); // fails in CTFE
>
> ir[0].raw = 13; // overwrites both ir[0] and ir[1]
> assert(ir[0].raw == 13);
> assert(ir[1].raw == 42); // fails in CTFE
>
> return ir;
> }
>
> void main()
> {
> enum expected = [Bytecode(13), Bytecode(42)];
> assert(getIr() == expected); // passes
> static assert(getIr() == expected); // fails
> }
(In reply to comment #5)
> Reduced the code from comment #2 further:
>
> struct Bytecode
> {
> int raw;
> }
>
> Bytecode[] getIr()
> {
> Bytecode[] ir;
>
> ir ~= Bytecode(42);
> ir ~= ir[0 .. 1]; // add .dup and CTFE gets it
> assert(&ir[0] != &ir[1]); // fails in CTFE
>
> ir[0].raw = 13; // overwrites both ir[0] and ir[1]
> assert(ir[0].raw == 13);
> assert(ir[1].raw == 42); // fails in CTFE
>
> return ir;
> }
>
> void main()
> {
> enum expected = [Bytecode(13), Bytecode(42)];
> assert(getIr() == expected); // passes
> static assert(getIr() == expected); // fails
> }
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list