Thread overview
[Issue 3288] New: conv.d : using to with cont int or long fails to compile.
Sep 03, 2009
sandford@jhu.edu
[Issue 3288] conv.d : using to with const int or long fails to compile.
Sep 03, 2009
Rob Jacques
Sep 04, 2009
HOSOKAWA Kenchi
Oct 06, 2009
Walter Bright
September 03, 2009
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)

Line# 2580 in dmd 2.032

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 03, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3288





--- Comment #1 from Rob Jacques <sandford@jhu.edu>  2009-09-03 10:04:55 PDT ---
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: -------
September 04, 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3288


HOSOKAWA Kenchi <hskwk@inter7.jp> changed:

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




--- Comment #2 from HOSOKAWA Kenchi <hskwk@inter7.jp>  2009-09-04 09:41:44 PDT ---
(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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 04, 2009
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




--- Comment #3 from Andrei Alexandrescu <andrei@metalanguage.com>  2009-09-04 10:42:04 PDT ---
(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!

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


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla@digitalmars.com> 2009-10-06 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: -------