[Issue 2398] New: writef("%x") for a pointer is always uppercase

d-bugmail at puremagic.com d-bugmail at puremagic.com
Tue Oct 7 01:47:41 PDT 2008


http://d.puremagic.com/issues/show_bug.cgi?id=2398

           Summary: writef("%x") for a pointer is always uppercase
           Product: D
           Version: 1.035
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Phobos
        AssignedTo: bugzilla at digitalmars.com
        ReportedBy: clugdbug at yahoo.com.au


prints ABCD, expect abcd. It's treating %x as if it were %X.
Applies to function pointers as well as data pointers.
Applies to writefln as well as writef.
Applies to DMD2.019 also.

This behaviour occurs because of line 794 of format.d, which sets uppercase to
1:
            case Mangle.Tpointer:
                vnumber = cast(ulong)va_arg!(void*)(argptr);
---->           uc = 1;
                flags |= FL0pad;


I can't see any reason for it, and I can't see this behaviour documented
anywhere (the docs for %x say that it must be an integral type, which isn't
true in this case).

FIX: remove line 794. Possibly adjust the docs for %x/%X, to state that "%x/%X
may be used for pointer types".

---
import std.stdio;

void main()
{
    uint *q = cast(uint *)0xabcd;
    writef("%x", q);
}


-- 



More information about the Digitalmars-d-bugs mailing list