www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9126] New: parse!int fails on size_t.max+1 digits long input (overflow)

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

           Summary: parse!int fails on size_t.max+1 digits long input
                    (overflow)
           Product: D
           Version: D1 & D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: nilsbossung googlemail.com



---
std.conv.parse!int uses a counter just to see if anything could be parsed.
When the counter overflows, the state jumps back to "at start", which is wrong,
of course.

Test case (takes some minutes):
---
import std.conv: parse;
import std.range: chain, repeat;
void main() {
    auto seven = chain(repeat(cast(dchar) '0', size_t.max), "7");
    assert(parse!int(seven) == 7);

    auto eleven = chain(repeat(cast(dchar) '0', size_t.max), "B");
    assert(parse!int(eleven, 13) == 11);
} 
---

Pull request follows.

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


Nils <nilsbossung googlemail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



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

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




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

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


Fix Issue 9126 - parse!int fails on size_t.max+1 digits long input (overflow)

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


Nils <nilsbossung googlemail.com> 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: -------
Dec 09 2012