SourceForge has been redesigned. Learn more.
Close

#145 "0x" missing in fprintf ("%p") output

OTHER
closed
gcc (462)
rejected
Known_bugs
2013-01-24
2002-05-30
No

Hi,

if you print a pointer using fprintf()'s "%p" format,
it doesn't include the leading "0x" like fprintf() on
cygwin or GNU/Linux does.

Martin

Discussion

  • Danny Smith

    Danny Smith - 2002-05-30

    Logged In: YES
    user_id=11494

    This is not a mingw bug. According to the ISO
    standard, the p specifier does this:
    "The argument shall be a pointer to void. The value of
    the pointer is converted to a sequence of printing
    characters, in an implementation-defined manner."

    It does not specify that the 0x is required.

    Danny

     
  • Danny Smith

    Danny Smith - 2002-05-30
    • summary: "0x" missing in fprintf ("%p") output --> "0x" missing in fprintf ("%p") output
     
  • Martin Baulig

    Martin Baulig - 2002-05-30
    • summary: "0x" missing in fprintf ("%p") output --> "0x" missing in fprintf ("%p") output
     
  • Martin Baulig

    Martin Baulig - 2002-05-30

    Logged In: YES
    user_id=555808

    Well, I call it a bug because both Cygwin and GNU/Linux print the
    "0x" - and the documentation of the GNU C Library also says
    that the "0x" is printed. Most most other Unixes do so as well.

    The current implementation makes the "%p" format totally
    useless, I'm not going to use some

    #ifdef MINGW32
    fprintf (out, "0x%lx", ptr);
    #else
    fprintf (out, "%p", ptr);
    #endif

    in my code to make my code portable.

    I thought mingw32 was called "Minimal GNU for Windows" - so
    why does it behave differently from the GNU system here ?

    Martin

     
  • Martin Baulig

    Martin Baulig - 2002-05-30

    Logged In: YES
    user_id=555808

    Your bug report is interesting to us. However, to save us time in research can you please let us know where we can
    find documentation supporting this bug report?

    Thank you for your interest in MinGW,
    The MinGW Project Administrators.

     
  • Luke Dunstan

    Luke Dunstan - 2002-05-31

    Logged In: YES
    user_id=30442

    The "GNU" in "MinGW" is because it is a port of the GNU
    compiler tools to Windows, not because it attempts to
    emulate the runtime environment of GNU systems (use
    Cygwin for that). Mingw differs from Linux/Cygwin because it
    uses the MS C Runtime instead of GNU libc (and this is
    the "minimalist" part). Since we don't provide the C library, we
    cannot change this behaviour, but it is not a bug anyway
    because there is no standard way to print a pointer (and it is
    only useful for debugging).

    Please note that even the GNU libc manual mentions that %p
    is not fully portable:

    "In the GNU system, non-null pointers are printed as
    unsigned integers, as if a `%#x' conversion were used. Null
    pointers print as `(nil)'. (Pointers might print differently in other
    systems.) "

    (http://www.gnu.org/manual/glibc-
    2.2.3/html_node/libc_186.html#SEC195)

    Different architectures would be different to x86 Linux too, but
    the simplest solution is to use "%#x" for both glibc and
    Mingw.

     
  • Danny Smith

    Danny Smith - 2002-06-01

    Logged In: YES
    user_id=11494

    I'm closing this because (1) it is not a bug and (2) if you
    want the 0X prefix you can use %#p . %#x, or %#X.
    Danny

     
  • Danny Smith

    Danny Smith - 2002-06-01
    • assigned_to: earnie --> dannysmith
    • summary: "0x" missing in fprintf ("%p") output --> "0x" missing in fprintf ("%p") output
    • status: open --> closed-rejected
     
  • Earnie Boyd

    Earnie Boyd - 2013-01-24
    • labels: mingw runtime (deprecated use WSL) --> gcc
    • Description has changed:

    Diff:

    
    
    • status: closed-rejected --> closed
    • resolution: --> rejected
    • category: --> Known_bugs
    • milestone: --> OTHER
     

Log in to post a comment.