www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 3288] New: conv.d : using to with cont int or long fails to compile.

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3288

           Summary: conv.d : using to with cont int or long fails to
                    compile.
           Product: D
           Version: 2.032
          Platform: x86
        OS/Version: Windows
            Status: NEW
          Keywords: patch
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: sandford jhu.edu


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)



-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3288






Better patch:

changing
auto u = -cast(Unsigned!S) value;
to
auto u = -cast(Unsigned!(typeof(value+0))) value;

on line 2575;

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 03 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3288


HOSOKAWA Kenchi <hskwk inter7.jp> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |hskwk inter7.jp





---

(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 04 2009
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3288


Andrei Alexandrescu <andrei metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |andrei metalanguage.com
         Resolution|                            |FIXED





10:42:04 PDT ---


 (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! -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Sep 04 2009
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=3288


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bugzilla digitalmars.com



02:22:05 PDT ---
Fixed dmd 2.033

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 06 2009