Notice: We have migrated to GitLab launching 2024-05-01 see here: https://gitlab.rtems.org/

#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 01/29/07 at 07:23:57 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 11/22/14 at 14:48:28 by Gedare Bloom

Description: modified (diff)
Milestone: 24.9.5

comment:3 Changed on 11/23/14 at 15:10:09 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.