Bug 1110 – std.format.doFormat + struct without toString() == crash

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D1 (retired)
Platform
x86
OS
All
Creation time
2007-04-08T09:42:00Z
Last change time
2014-02-16T15:23:13Z
Keywords
patch
Assigned to
bugzilla
Creator
fvbommel

Attachments

IDFilenameSummaryContent-TypeSize
137format.patchProposed patchtext/plain460

Comments

Comment #0 by fvbommel — 2007-04-08T09:42:00Z
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.
Comment #1 by fvbommel — 2007-04-08T09:43:18Z
Created attachment 137 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.
Comment #2 by bugzilla — 2007-07-30T15:48:12Z
Fixed DMD 1.019 and 2.003