[Issue 3333] New: std.conv.to!(string, const int) error: cannot modify const

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Sep 20 04:45:04 PDT 2009


http://d.puremagic.com/issues/show_bug.cgi?id=3333

           Summary: std.conv.to!(string, const int) error: cannot modify
                    const
           Product: D
           Version: 2.032
          Platform: All
        OS/Version: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: lutger.blijdestijn at gmail.com


--- Comment #0 from Lutger <lutger.blijdestijn at gmail.com> 2009-09-20 04:45:01 PDT ---
import std.conv;

void main()
{
    assert( to!string( cast(const int)1) == "1" );
}

errors:
src/phobos/std/conv.d(2580): Error: variable
std.conv.to!(immutable(char)[],const(int)).to.u cannot modify const
src/phobos/std/conv.d(5): Error: template instance std.conv.to!(immutable(char)
[],const(int)) error instantiating


Possible fix:

@@ -2570,11 +2570,11 @@
         return to!T(cast(Unsigned!(S)) value);

     alias Unqual!(ElementType!T) Char;
     Char[1 + S.sizeof * 3] buffer;

-    auto u = -cast(Unsigned!S) value;
+    Unqual!S u = -cast(Unsigned!S) value;
     uint ndigits = 1;
     while (u)
     {
         immutable c = cast(char)((u % 10) + '0');
         u /= 10;

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


More information about the Digitalmars-d-bugs mailing list