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

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sat Dec 8 23:40:07 PST 2012


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 at puremagic.com
        ReportedBy: nilsbossung at googlemail.com


--- Comment #0 from Nils <nilsbossung at googlemail.com> 2012-12-08 23:40:03 PST ---
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: -------


More information about the Digitalmars-d-bugs mailing list