Bug 3288 – conv.d : using to with const int or long fails to compile.
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2009-09-03T09:55:00Z
Last change time
2015-06-09T01:26:48Z
Keywords
patch
Assigned to
nobody
Creator
sandford
Comments
Comment #0 by sandford — 2009-09-03T09:55:30Z
The to!string conversion template doesn't handle const int or long values i.e.
const h = 6;
string s = to!string(h); // Error
This seems to effect text, but not writeln.
Patch:
change
u /= 10;
to
u = u / 10;
inside
/// Signed values ($(D int) and $(D long)).
T to(T, S)(S value)
if (staticIndexOf!(Unqual!S, int, long) >= 0 && isSomeString!T)
Line# 2580 in dmd 2.032
Comment #1 by sandford — 2009-09-03T10:04:55Z
Better patch:
changing
auto u = -cast(Unsigned!S) value;
to
auto u = -cast(Unsigned!(typeof(value+0))) value;
on line 2575;
Comment #2 by hskwk — 2009-09-04T09:41:44Z
(In reply to comment #1)
(maybe) more better patch:
2575: auto u = -cast(Unqual!(Unsigned!S)) value;
Just you need is removing qualifier from S.
std.traits.Unqual is the best way to do it.
Comment #3 by andrei — 2009-09-04T10:42:04Z
(In reply to comment #2)
> (In reply to comment #1)
> (maybe) more better patch:
>
> 2575: auto u = -cast(Unqual!(Unsigned!S)) value;
>
> Just you need is removing qualifier from S.
> std.traits.Unqual is the best way to do it.
Fixed as you suggested, coming with 2.033. Thanks!