#1214 closed defect

inttypes.h's PRI*PTR uses %*ll where it should use %*l

Reported by: Ralf Corsepius Owned by: Ralf Corsepius
Priority: normal Milestone: 4.11
Component: tool/newlib Version: 4.7
Severity: normal Keywords:
Cc: Blocked By:
Blocking:

Description (last modified by Gedare Bloom)

newlib-1.15.0's inttypes.h's implementation of the
PRI*PTR macros is broken.

The %*l macro being chosen doesn't correspond to the type being used as intptr_t.

To reproduce, compile this:

cat tmp.c

#include <stdio.h>
#include <inttypes.h>

int main()
{

void *null = 0;
printf( "%" PRIxPTR "\n", (intptr_t) null );
return 0;

}

# for c in /opt/rtems-4.8/bin/*-rtems4.8-gcc; do \
echo "$c:"; $c -o tmp.o -Wall -c tmp.c; done

/opt/rtems-4.8/bin/arm-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/avr-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/bfin-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/h8300-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/i386-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/m68k-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/mips-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/powerpc-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/sparc-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/tic4x-rtems4.8-gcc:
tmp.c: In function `main':
tmp.c:7: warning: long long unsigned int format, different type arg (arg 2)

Affected are all targets on all rtems branches.

Change History (3)

comment:1 Changed on Jan 29, 2007 at 7:23:57 AM by Ralf Corsepius

newlib-1.15.0's inttypes.h's implementation of the
PRI*PTR macros is broken.

The %*l macro being chosen doesn't correspond to the type being used as intptr_t.

To reproduce, compile this:

cat tmp.c

#include <stdio.h>
#include <inttypes.h>

int main()
{

void *null = 0;
printf( "%" PRIxPTR "\n", (intptr_t) null );
return 0;

}

# for c in /opt/rtems-4.8/bin/*-rtems4.8-gcc; do \
echo "$c:"; $c -o tmp.o -Wall -c tmp.c; done

/opt/rtems-4.8/bin/arm-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/avr-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/bfin-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/h8300-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/i386-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/m68k-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'long int'

/opt/rtems-4.8/bin/mips-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/powerpc-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/sparc-rtems4.8-gcc:
tmp.c: In function 'main':
tmp.c:7: warning: format '%llx' expects type 'long long unsigned int', but argument 2 has type 'int'

/opt/rtems-4.8/bin/tic4x-rtems4.8-gcc:
tmp.c: In function `main':
tmp.c:7: warning: long long unsigned int format, different type arg (arg 2)

Affected are all targets on all rtems branches.

comment:2 Changed on Nov 22, 2014 at 2:48:28 PM by Gedare Bloom

Description: modified (diff)
Milestone: 24.9.5

comment:3 Changed on Nov 23, 2014 at 3:10:09 PM by Joel Sherrill

Milestone: 4.9.54.11
Resolution: fixed
Status: newclosed
Version: unknown4.7

Reported years ago against an old newlib but not worked on until recently. The fix will not be backported. But it is fixed now.

Note: See TracTickets for help on using tickets.