www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 7944] New: popFront() cycles when the range is empty

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

           Summary: popFront() cycles when the range is empty
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: lovelydear mailmetrash.com


--- Comment #0 from SomeDude <lovelydear mailmetrash.com> 2012-04-19 05:38:23
PDT ---
Original discussion:
http://forum.dlang.org/post/itrsidszogvnobzvlbwg forum.dlang.org

import std.range, std.stdio;

void main()
{
   auto r = iota(3);

   writeln(r.front, ", length: ", r.length, " empty ? ", r.empty);
   r.popFront();
   writeln(r.front, ", length: ", r.length, " empty ? ", r.empty);
   r.popFront();
   writeln(r.front, ", length: ", r.length, " empty ? ", r.empty);
   r.popFront();
   writeln(r.front, ", length: ", r.length, " empty ? ", r.empty);
   r.popFront();
   writeln(r.front, ", length: ", r.length, " empty ? ", r.empty);
   r.popFront();
}

Returns:
0, length: 3 empty ? false
1, length: 2 empty ? false
2, length: 1 empty ? false
3, length: 0 empty ? true
4, length: 4294967295 empty ? false

Shouldn't popFront() assert when r.empty == true ?

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


Steven Schveighoffer <schveiguy yahoo.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Severity|normal                      |enhancement


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


hsteoh quickfur.ath.cx changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hsteoh quickfur.ath.cx


--- Comment #1 from hsteoh quickfur.ath.cx 2012-04-19 07:34:28 PDT ---
iota should have an in-contract that asserts !empty.

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



--- Comment #2 from Brad Anderson <eco gnuk.net> 2012-04-19 19:04:44 PDT ---
https://github.com/D-Programming-Language/phobos/pull/545

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



--- Comment #3 from github-bugzilla puremagic.com 2012-04-22 18:03:23 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/028699fe6ca3defa598fef65ffd287e7e3626f72
fix Issue 7944 - std.range.iota.popFront() cycles when the range is empty

Added !empty assertions to front, popFront, back, and popBack to the integer
iota like some other ranges do. Also added the one that was missing to the
floating point iota.

https://github.com/D-Programming-Language/phobos/commit/9233d3d20d18e2babf5395c4fb934c800b27ca7d
Merge pull request #545 from eco/iota-pop-empty

fix Issue 7944 - std.range.iota.popFront() cycles when the range is empty

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


Brad Anderson <eco gnuk.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED


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