possible bug in std.conv.parse

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Sat Apr 26 16:43:41 PDT 2014


ketmar:

> this code: std.conv.parse!byte("-128") throws error: "Overflow 
> in integral conversion". but this is obviously not true, as 
> signed byte can hold such value.
>
> the question is: is it bug, or it's intended behavior to limit 
> signed integrals to values which can be safely abs()ed?

This code works to me:

void main() {
     import std.conv: to, parse;
     auto s1 = "-128";
     assert(s1.parse!byte == -128);
     immutable s2 = "-128";
     assert(s2.to!byte == -128);
}


What's your compiler version?

Bye,
bearophile


More information about the Digitalmars-d mailing list