This is the mail archive of the mailing list for the newlib project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] stdio: fix nano-vfprintf pointer formating with long pointers

On the MSP430 when building with -mlarge sizeof(void*) is larger than
sizeof(int), resulting in an offset error extracting arguments to format
strings that include %p.

2014-11-19  Peter A. Bigot  <>

        * libc/stdio/nano-vfprintf_i.c (_printf_i): Use LONGINT when void* is
        larger than an int.

Signed-off-by: Peter A. Bigot <>
 newlib/libc/stdio/nano-vfprintf_i.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/newlib/libc/stdio/nano-vfprintf_i.c b/newlib/libc/stdio/nano-vfprintf_i.c
index b75a142..992173b 100644
--- a/newlib/libc/stdio/nano-vfprintf_i.c
+++ b/newlib/libc/stdio/nano-vfprintf_i.c
@@ -150,8 +150,10 @@ _printf_i (struct _reent *data, struct _prt_data_t *pdata, FILE *fp,
        * defined manner.''
        *	-- ANSI X3J11
-      /* NOSTRICT.  */
       pdata->flags |= HEXPREFIX;
+      if (sizeof(void*) > sizeof(int))
+        pdata->flags |= LONGINT;
+      /* NOSTRICT.  */
     case 'x':
       pdata->l_buf[2] = 'x';
       xdigs = "0123456789abcdef";

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]