www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8551] New: Endless Split

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8551

           Summary: Endless Split
           Product: D
           Version: unspecified
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: major
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: daniel350 bigpond.com



PDT ---
import std.array;

void main() {
      auto s = "abc";
      auto r = s.split("");

      assert(false); // won't ever be reached
}


The assert is never reached, for whatever reason, the compiler hangs (possible
in an infinite loop somewhere).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 15 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8551




PDT ---
Warning, this will cause a memory explosion and you *will* eventually get an
OutOfMemoryException.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8551




PDT ---
import std.algorithm;
import std.stdio;

void main() {
      auto s = "abc";
      writeln(s.find("").length); // prints 3 - what the?
      writeln(s.find(",").length); // prints 0 - expected
      writeln(s.find("b").length); // prints 2 - expected
}

The problem is from the second implementation of the `splitter` in
std/algorithm.d (:2118). Possibly rooted in erroneous output from find (see
above).

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8551




PDT ---

 import std.algorithm;
 import std.stdio;
 
 void main() {
       auto s = "abc";
       writeln(s.find("").length); // prints 3 - what the?
       writeln(s.find(",").length); // prints 0 - expected
       writeln(s.find("b").length); // prints 2 - expected
 }
 
 The problem is from the second implementation of the `splitter` in
 std/algorithm.d (:2118). Possibly rooted in erroneous output from find (see
 above).
As was explained to me by CyberShadow, it does not appear to be erroneous output from find; but most likely just an edge case in splitter. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8551




PDT ---
The culprit lies in the fact that when find() returns a string the same length
as the input; _frontLength is then left as `0`.

This later leads to the following result in popFront():

_input = _input[_frontLength + separatorLength .. _input.length];

is equal to

_input = _input[0 .. _input.length];

Ie, unchanged.
Therefore, the range remains the same length, and never completes.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 16 2012
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8551


monarchdodra gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |monarchdodra gmail.com
         Resolution|                            |DUPLICATE



*** This issue has been marked as a duplicate of issue 5977 ***

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 22 2012