Thread overview
[Issue 4635] New: to!string fails for Variant and structs with uninitalized ("=void") static arrays
Aug 12, 2010
Lionello Lunesu
May 26, 2011
Andrej Mitrovic
August 12, 2010
http://d.puremagic.com/issues/show_bug.cgi?id=4635

           Summary: to!string fails for Variant and structs with
                    uninitalized ("=void") static arrays
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody@puremagic.com
        ReportedBy: lio+bugzilla@lunesu.com


--- Comment #0 from Lionello Lunesu <lio+bugzilla@lunesu.com> 2010-08-12 15:26:10 PDT ---
Repro:

struct S
{
  ubyte[1] raw = void;
}
static assert(is(typeof(S.init)));//fails


std/conv.d, line 256:

T to(T, S)(S s)
if (is(S == struct) && isSomeString!(T) && is(typeof(&S.init.toString)))

The last part is(typeof(&S.init.toString)) cannot be evaluated for structs
which have unitialized static arrays. This is true for std.variant.Variant.
(This might be a compiler bug, I'm not sure.)

I've fixed it by removing the ".init" on std/conv.d line 257 and 274. With this change Variant can be directly printed, since to!string will detect the toString member function.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
January 09, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4635


Andrei Alexandrescu <andrei@metalanguage.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |ASSIGNED
                 CC|                            |andrei@metalanguage.com
         AssignedTo|nobody@puremagic.com        |andrei@metalanguage.com


-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=4635


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
                 CC|                            |andrej.mitrovich@gmail.com
         Resolution|                            |FIXED


--- Comment #1 from Andrej Mitrovic <andrej.mitrovich@gmail.com> 2011-05-26 14:30:52 PDT ---
Seems to work in 2.053:

import std.conv;
import std.stdio;

struct S
{
  ubyte[1] raw = void;
}
static assert(is(typeof(S.init)));  // ok

void main() { S s; writeln(to!string(s)); }  // ok

Marking as fixed.

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