D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 7107 - Compiled program aborts when using foreach and std.regex.splitter
Summary: Compiled program aborts when using foreach and std.regex.splitter
Status: RESOLVED WORKSFORME
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: x86_64 Linux
: P2 normal
Assignee: No Owner
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-12-14 04:07 UTC by Tomoya Tanjo
Modified: 2014-05-07 18:21 UTC (History)
1 user (show)

See Also:


Attachments
The output of the compiled program (3.34 KB, text/x-log)
2011-12-14 04:07 UTC, Tomoya Tanjo
Details

Note You need to log in before you can comment on or make changes to this issue.
Description Tomoya Tanjo 2011-12-14 04:07:20 UTC
Created attachment 1052 [details]
The output of the compiled program

When I compiled the following code with DMD v2.057 with -inline option,
the compiled program aborts in runtime (on Linux 64bit).

When I use regex("h") or regex(" ") instead of regex("  "),
this code works correctly.

issue.d:
----------------------------------------------------

import std.regex;
import std.stdio;

void main() {
  foreach(w; splitter("hoge fuga", regex("  "))) {
    writeln(w);
    writeln(w.length);
  }
}

----------------------------------------------------

I attached the output of the compiled program.
Comment 1 Kenji Hara 2011-12-14 04:26:02 UTC
This problem does not occurs in Windows 7 64bit.

Output is:
----
hoge fuga
9
----
Comment 2 Dmitry Olshansky 2012-04-19 10:52:44 UTC
Can't reproduce with 2.059 on Fedora x86_64.

I tried:
dmd x.d 
dmd -inline -O x.d
dmd -m64 -inline -O x.d
dmd -m64 -inline x.d

All work. It's either a problem with your specific setup or it was fixed somewhere between 2.057-2.059.
Comment 3 github-bugzilla 2014-05-07 18:21:50 UTC
Commit pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/33f2ab82bd9fb51d88927b8048d88c30ea44111e
Remove code for bug 7107 and 10296 because they are unnecessary anymore.

Now instantiated symbols can reach correct "parent" via `Dsymbol::toParent2()`, because `TemplateInstance::enclosing` is properly calculated in `TemplateInstance::hasNestedArgs`.