Bug 6668 – Wrong "to" conversion stack trace

Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2011-09-14T11:18:00Z
Last change time
2013-01-21T00:23:30Z
Keywords
diagnostic, pull
Assigned to
andrej.mitrovich
Creator
bearophile_hugs

Comments

Comment #0 by bearophile_hugs — 2011-09-14T11:18:05Z
D2 code: import std.conv; void main() { to!uint("-1"); } With DMD 2.055 it gives a strange stack trace on Windows (and on one Linux), that I am not sure is correct: std.conv.ConvException@...\src\phobos\std\conv.d(1809): Can't convert value `-1' of type string to type uint ---------------- ...\src\phobos\std\conv.d(1810): uint std.conv.parse!(uint, immutable(char)[]).parse(ref immutable(char)[]) ...\src\phobos\std\conv.d(1643): uint std.conv.toImpl!(uint, immutable(char)[]).toImpl(immutable(char)[]) ...\src\phobos\std\conv.d(234): uint std.conv.to!(uint).to!(immutable(char)[]).to(immutable(char)[]) ...\test.d(3): _Dmain ---------------- std.conv.ConvException@...\src\phobos\std\conv.d(1640): Can't convert value `-1' of type string to type uint ---------------- ...\src\phobos\std\conv.d(1640): uint std.conv.toImpl!(uint, immutable(char)[]).toImpl(immutable(char)[]) ...\src\phobos\std\conv.d(234): uint std.conv.to!(uint).to!(immutable(char)[]).to(immutable(char)[]) ...\test.d(3): _Dmain ----------------
Comment #1 by andrej.mitrovich — 2013-01-19T22:13:00Z
It's caused by collateral exceptions due to scope(exit) being used in std.conv which throws it's own exception regardless of any already in flight. I think these should actually be scope(success) instead.
Comment #2 by andrej.mitrovich — 2013-01-20T08:31:29Z
Comment #3 by github-bugzilla — 2013-01-21T00:23:15Z
Commits pushed to master at https://github.com/D-Programming-Language/phobos https://github.com/D-Programming-Language/phobos/commit/88c2c81fbcc8cbc718f1f7bdbf7da017a18a2516 Fixes Issue 6668 - Avoid throwing collateral exceptions in std.conv.to https://github.com/D-Programming-Language/phobos/commit/8f85f6bdaa985a32773442b8dc1932e1d9796436 Merge pull request #1081 from AndrejMitrovic/Fix6668 Issue 6668 - Avoid throwing collateral exceptions in std.conv.to