www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 12181] New: to!string fails on arrays of floats

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

           Summary: to!string fails on arrays of floats
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: turkeyman gmail.com


--- Comment #0 from Manu <turkeyman gmail.com> 2014-02-16 05:11:38 PST ---
Should this work?

 enum float[4] x = [0,1,2,3]; // fixed array
 pragma(msg, to!string(x));

1>src\db\performance.d(159): Error: template std.conv.to does not match any
function template declaration. Candidates are:
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(276):       
std.conv.to(T)
1>src\db\performance.d(159): Error: template std.conv.to(T) cannot deduce
template function from argument types !(string)(float[4])
1>src\db\performance.d(160):        while evaluating pragma(msg, s)


Another:

 enum float[] x = [0,1,2,3]; // dynamic array
 pragma(msg, to!string(x));

1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\math.d(3892): Error: Cannot
convert &real to ushort* at compile time
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(1568):        called
from here: isNaN(cast(real)val)
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(2373):        called
from here: formatValue(w, val, f)
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(2185):        called
from here: formatElement(w, front(val), f)
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\format.d(1904):        called
from here: formatRange(w, obj, f)
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(107):        called
from here: formatValue(w, src, f)
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(866):        called
from here: toStr(value)
1>C:\dev\D\dmd2\windows\bin\..\..\src\phobos\std\conv.d(281):        called
from here: toImpl(_param_0)
1>src\db\performance.d(159):        called from here: to([0.000000F, 1.00000F,
2.00000F, 3.00000F])
1>src\db\performance.d(160):        while evaluating pragma(msg, s)


It does seem to work with arrays of int's.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2014
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12181



--- Comment #1 from Manu <turkeyman gmail.com> 2014-02-16 05:12:44 PST ---
Actually, int[] works, but int[4] doesn't work.
So it seems arrays of floats fail, also, fixed length arrays fail.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Feb 16 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=12181


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com
           Platform|x86_64                      |All
         OS/Version|Windows                     |All


--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2014-02-16
05:18:25 PST ---
Typical workaround would be:

pragma(msg, to!string(x[]));

But this only works at runtime, at CT it's an error:

C:\dmd-git\dmd2\windows\bin\..\..\src\phobos\std\format.d(1623): Error:
_snprintf cannot be interpreted at compile time, because it has no available
source code

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