www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 1110] New: std.format.doFormat + struct without toString() == crash

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

           Summary: std.format.doFormat + struct without toString() == crash
           Product: D
           Version: 1.010
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: fvbommel wxs.nl


When formatting a struct instance, std.format.doFormat doesn't check whether
TypeInfo_Struct.xtoString is null before calling it. IMHO it should check for
this and throw an exception if it's null.


-- 
Apr 08 2007
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1110






Created an attachment (id=137)
 --> (http://d.puremagic.com/issues/attachment.cgi?id=137&action=view)
Proposed patch

Adds
=====
if (tis.xtoString is null)
    throw new FormatError("Can't convert " ~ tis.toString() ~ " to string:
\"char[] toString()\" not defined");
=====
when formatting a struct.


-- 
Apr 08 2007
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=1110


bugzilla digitalmars.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED





Fixed DMD 1.019 and 2.003


-- 
Jul 30 2007