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