Bug 4635 – to!string fails for Variant and structs with uninitalized ("=void") static arrays

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
Other
OS
Windows
Creation time
2010-08-12T15:26:00Z
Last change time
2011-05-26T14:30:52Z
Assigned to
andrei
Creator
lio+bugzilla

Comments

Comment #0 by lio+bugzilla — 2010-08-12T15:26:10Z
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.
Comment #1 by andrej.mitrovich — 2011-05-26T14:30:52Z
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.