www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11778] New: format for null does not verify fmt flags.

reply d-bugmail puremagic.com writes:
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 puremagic.com
        ReportedBy: monarchdodra gmail.com



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 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: -------
Dec 19 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778


Andrej Mitrovic <andrej.mitrovich gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |andrej.mitrovich gmail.com



06:39:59 PST ---
Where is 's' defined?

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778




06:41:48 PST ---
I guess this could be a test-case:

-----
import std.stdio;
void main()
{
    string s = "%d";
    int* p;
    writefln(s, p);  // does not throw
    writefln(s, p + 1);
}
-----

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Dec 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778





 Where is 's' defined?
Hum... I forgot to copy paste it. Much apologies. I had defined it as: enum s = "%d"
 I guess this could be a test-case:
 
 -----
 import std.stdio;
 void main()
 {
     string s = "%d";
     int* p;
     writefln(s, p);  // does not throw
     writefln(s, p + 1);
 }
 -----
Yes, exactly. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Dec 20 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull



https://github.com/D-Programming-Language/phobos/pull/2069

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2014
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778




Commits pushed to master at https://github.com/D-Programming-Language/phobos

https://github.com/D-Programming-Language/phobos/commit/b32e4032c1adbdabd4cdcfe3599606d806762038
fix Issue 11778 - format for null does not verify fmt flags.

https://github.com/D-Programming-Language/phobos/commit/f8288c7ea321cfee94561f70a64fc01f81c7ae10


Issue 11778 - format for null does not verify fmt flags.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 03 2014
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11778


Kenji Hara <k.hara.pg gmail.com> changed:

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


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