[Issue 11778] New: format for null does not verify fmt flags.

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Dec 19 12:42:55 PST 2013


https://d.puremagic.com/issues/show_bug.cgi?id=11778

           Summary: format for null does not verify fmt flags.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: nobody at puremagic.com
        ReportedBy: monarchdodra at gmail.com


--- Comment #0 from monarchdodra at gmail.com 2013-12-19 12:42:54 PST ---
Printing pointer types is supposed to only work with %X, %x or %s.

However, if the passed pointer is null, there is no actual fmt validation:

//----
import std.stdio;
void main()
{
    int* p;
    writefln(s, p);
    writefln(s, p + 1);
}
//----
null
std.format.FormatException at std/format.d(2957): Expected one of %s, %x or %X for
pointer type.
//----

This can be an issue, as an invalid format flag may end up throwing depending
on the *value* passed (and not the type). The bug may only reveal itself
unexpectedly at a later date.

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


More information about the Digitalmars-d-bugs mailing list