This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc 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]

[Bug libc/5424] New: printf doesn't behave correctly with huge numbers of characters


When the number of characters is > INT_MAX, printf doesn't return the number of
output characters. The C standard seems to be silent on this point and the
current glibc manual and printf(3) man page are also silent. The following
program was tested on a Debian/etch x86_64 machine:

#ifndef N
#define N 2147483648
#endif

#define STRINGIFY(S) #S
#define MAKE_STR(S) STRINGIFY(S)

#define SN MAKE_STR(N)

#include <stdio.h>

int main (void)
{
  int ret;

  ret = printf ("%" SN "d%" SN "d", 1, 1);
  fprintf (stderr, "ret = %d\n", ret);
  return 0;
}

$ ./ret-printf | wc -c
ret = 0
4294967296

I don't know how such cases should be handled, but returning a non-negative
value different from the number of output characters is incorrect.

Moreover, printf doesn't handle field widths larger than 2^31.

-- 
           Summary: printf doesn't behave correctly with huge numbers of
                    characters
           Product: glibc
           Version: unspecified
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper at redhat dot com
        ReportedBy: vincent+libc at vinc17 dot org
                CC: glibc-bugs at sources dot redhat dot com


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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