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

D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 1110 - std.format.doFormat + struct without toString() == crash
Summary: std.format.doFormat + struct without toString() == crash
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D1 (retired)
Hardware: x86 All
: P2 normal
Assignee: Walter Bright
URL:
Keywords: patch
Depends on:
Blocks:
Reported: 2007年04月08日 09:42 UTC by Frits van Bommel
Modified: 2014年02月16日 15:23 UTC (History)
0 users

See Also:


Attachments
Proposed patch (460 bytes, patch)
2007年04月08日 09:43 UTC, Frits van Bommel
Details | Diff
Add an attachment (proposed patch, testcase, etc.)

Note You need to log in before you can comment on or make changes to this issue.
Description Frits van Bommel 2007年04月08日 09:42:00 UTC
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 Frits van Bommel 2007年04月08日 09:43:18 UTC
Created attachment 137 [details] 
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 Walter Bright 2007年07月30日 15:48:12 UTC
Fixed DMD 1.019 and 2.003


AltStyle によって変換されたページ (->オリジナル) /