tkchia / newlib-ia16

Fork of IA-16 port of Newlib -- added small and medium model support
GNU General Public License v2.0
13 stars 4 forks source link

printf() is broken for int64 types #16

Closed iucoen closed 2 years ago

iucoen commented 2 years ago

I tried both %llx and %qx, but in both cases, only 4 bytes are being taken off va_args. Causing rest of the arguments to be shifted.

Example code:

#include <stdint.h>
#include <stdio.h>

int main()
{
  uint64_t a = 0x1234567890abcdef;
  uint64_t b = 0xabcedf1234567890;
  printf("%qx %qx\r\n", a, b);
  return 0;
}

Expected output:

1234567890abcdef abcedf1234567890

Actual output:

90abcdef 12345678
andrewbird commented 2 years ago

Do you get the same result using the PRIx64 macro from inttypes.h?

iucoen commented 2 years ago

Do you get the same result using the PRIx64 macro from inttypes.h?

PRIx64 is just "llx" so yes.

tkchia commented 2 years ago

Hello @iucoen, hello @andrewbird,

Oops — there was an oversight on my part. This problem should now be fixed in my main Git branch.

Thank you!