www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 6222] New: A problem with iota() using size_t

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

           Summary: A problem with iota() using size_t
           Product: D
           Version: D2
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: bearophile_hugs eml.cc



With DMD 2.053 this apparently goes in infinite loop:


import std.range;
void main() {
    string s;
    foreach (i; iota(0, s.length, 3)) {}
}


What I expect: the foreach loop to loop zero times instead.

See also bug 4603

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Jun 29 2011
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=6222


Brad Anderson <eco gnuk.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |eco gnuk.net



https://github.com/D-Programming-Language/phobos/pull/547

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




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/6b92abb0449e6af80f68beb9fa1311346397bfaf
fix Issue 6222 - A problem with iota() using size_t

If the common type of begin and end is unsigned and end is 0 the private
member pastEnd ends up being unsigned.max due to "pastEnd - 1" (used to make
end not inclusive) which results in iota behaving incorrectly. A simple change
to always make an empty range when begin==end prevents this.

Also fixed and clarified the documentation.

https://github.com/D-Programming-Language/phobos/commit/b1252f35afc019c37f334d274c257a25a4e0035f


fix Issue 6222 - A problem with iota() using size_t

-- 
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=6222


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