December 23, 2006 [Issue 733] New: std.conv.toFloat does not catch errors | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=733 Summary: std.conv.toFloat does not catch errors Product: D Version: 0.177 Platform: All OS/Version: All Status: NEW Severity: minor Priority: P2 Component: Phobos AssignedTo: bugzilla@digitalmars.com ReportedBy: dvdfrdmn@users.sf.net In rare cases, toFloat will not throw an exception on invalid input. Also affects toDouble and toReal. ------- import std.conv; import std.stdio; void main() { char[] b = "\x00"; bool ok = false; try { float f = toFloat(b); } catch (ConvError e) { ok = true; } assert(ok); } ------- General fix: f = strtof(sz, &endptr); if (getErrno() == ERANGE) goto Lerr; - if (endptr && (endptr == s.ptr || *endptr != 0)) + if (endptr && (endptr == sz || *endptr != 0)) goto Lerr; return f; -- |
November 04, 2007 [Issue 733] std.conv.toFloat does not catch errors | ||||
---|---|---|---|---|
| ||||
Posted in reply to d-bugmail | http://d.puremagic.com/issues/show_bug.cgi?id=733 bugzilla@digitalmars.com changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |FIXED ------- Comment #1 from bugzilla@digitalmars.com 2007-11-03 21:45 ------- Fixed dmd 1.023 (already worked in 2.006) -- |
Copyright © 1999-2021 by the D Language Foundation