public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12593] New: PRI*8 and PRI*16 formats use too many bits
@ 2011-03-18 13:49 christophe.lyon at st dot com
  2011-03-18 15:11 ` [Bug libc/12593] " joseph at codesourcery dot com
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: christophe.lyon at st dot com @ 2011-03-18 13:49 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12593

           Summary: PRI*8 and PRI*16 formats use too many bits
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: christophe.lyon@st.com


Created attachment 5318
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5318
patch for inttypes.h

I have noticed that inttypes.h formats such as PRIx8 are actually defined as
"x", while it should be "hhx". In the current form, too many bits are printed.

In attachment, I propose a patch which changes all the variants. (this patch is
created against the inttypes.h installed on my host machine, as I am not
familiar with glibc's sources)

Note that I am unsure why PRI*FAST16 and PRI*FAST32 currently use
__PRIPTR_PREFIX, and I have changed the PRI*FAST16 variants to use "h" instead.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/12593] PRI*8 and PRI*16 formats use too many bits
  2011-03-18 13:49 [Bug libc/12593] New: PRI*8 and PRI*16 formats use too many bits christophe.lyon at st dot com
@ 2011-03-18 15:11 ` joseph at codesourcery dot com
  2011-03-18 15:20 ` christophe.lyon at st dot com
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2011-03-18 15:11 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12593

--- Comment #1 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-03-18 15:10:47 UTC ---
On Fri, 18 Mar 2011, christophe.lyon at st dot com wrote:

> I have noticed that inttypes.h formats such as PRIx8 are actually defined as
> "x", while it should be "hhx". In the current form, too many bits are printed.

This makes no difference for any valid arguments to those formats (i.e., 
arguments promoted from the relevant type).

> Note that I am unsure why PRI*FAST16 and PRI*FAST32 currently use
> __PRIPTR_PREFIX, and I have changed the PRI*FAST16 variants to use "h" instead.

Please read stdint.h.  The formats need to match the types there, and the 
16-bit and 32-bit *fast* types are int for 32-bit systems and long for 
64-bit systems, so the formats must match that.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/12593] PRI*8 and PRI*16 formats use too many bits
  2011-03-18 13:49 [Bug libc/12593] New: PRI*8 and PRI*16 formats use too many bits christophe.lyon at st dot com
  2011-03-18 15:11 ` [Bug libc/12593] " joseph at codesourcery dot com
@ 2011-03-18 15:20 ` christophe.lyon at st dot com
  2011-03-18 15:49 ` joseph at codesourcery dot com
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: christophe.lyon at st dot com @ 2011-03-18 15:20 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12593

--- Comment #2 from christophe.lyon at st dot com <christophe.lyon at st dot com> 2011-03-18 15:20:36 UTC ---
Well, if I compile & execute this sample code, there is a difference:
#include <stdio.h>
#include <inttypes.h>

int main()
{
    char v=0xf0;

    printf("char %hhx\n", v);
    printf("short %hx\n", v);
    printf("int %x\n", v);

    printf("char pri %" PRIx8 "\n", v);
    printf("short pri %" PRIx16 "\n", v);
    printf("int pri %" PRIx32 "\n", v);

    return 0;
}

At execution:
char f0
short fff0
int fffffff0
char pri fffffff0
short pri fffffff0
int pri fffffff0

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/12593] PRI*8 and PRI*16 formats use too many bits
  2011-03-18 13:49 [Bug libc/12593] New: PRI*8 and PRI*16 formats use too many bits christophe.lyon at st dot com
  2011-03-18 15:11 ` [Bug libc/12593] " joseph at codesourcery dot com
  2011-03-18 15:20 ` christophe.lyon at st dot com
@ 2011-03-18 15:49 ` joseph at codesourcery dot com
  2011-03-20 12:12 ` drepper.fsp at gmail dot com
  2014-06-27 13:40 ` fweimer at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: joseph at codesourcery dot com @ 2011-03-18 15:49 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12593

--- Comment #3 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2011-03-18 15:49:03 UTC ---
On Fri, 18 Mar 2011, christophe.lyon at st dot com wrote:

> Well, if I compile & execute this sample code, there is a difference:

This code is not a valid program; it has undefined behavior at runtime.  
The argument to PRIx8 must be uint8_t, not char (which I suppose is signed 
on your system); that for PRIx16 must be uint16_t; that for PRIx32 must be 
uint32_t.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/12593] PRI*8 and PRI*16 formats use too many bits
  2011-03-18 13:49 [Bug libc/12593] New: PRI*8 and PRI*16 formats use too many bits christophe.lyon at st dot com
                   ` (2 preceding siblings ...)
  2011-03-18 15:49 ` joseph at codesourcery dot com
@ 2011-03-20 12:12 ` drepper.fsp at gmail dot com
  2014-06-27 13:40 ` fweimer at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-03-20 12:12 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12593

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

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

--- Comment #4 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-03-20 12:12:13 UTC ---
Plainly invalid assumptions.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* [Bug libc/12593] PRI*8 and PRI*16 formats use too many bits
  2011-03-18 13:49 [Bug libc/12593] New: PRI*8 and PRI*16 formats use too many bits christophe.lyon at st dot com
                   ` (3 preceding siblings ...)
  2011-03-20 12:12 ` drepper.fsp at gmail dot com
@ 2014-06-27 13:40 ` fweimer at redhat dot com
  4 siblings, 0 replies; 6+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 13:40 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=12593

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2014-06-27 13:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-03-18 13:49 [Bug libc/12593] New: PRI*8 and PRI*16 formats use too many bits christophe.lyon at st dot com
2011-03-18 15:11 ` [Bug libc/12593] " joseph at codesourcery dot com
2011-03-18 15:20 ` christophe.lyon at st dot com
2011-03-18 15:49 ` joseph at codesourcery dot com
2011-03-20 12:12 ` drepper.fsp at gmail dot com
2014-06-27 13:40 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).