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/13575] New: SSIZE_MAX defined as LONG_MAX is inconsistent with SIZE_MAX, when __WORDSIZE != 64


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

             Bug #: 13575
           Summary: SSIZE_MAX defined as LONG_MAX is inconsistent with
                    SIZE_MAX, when __WORDSIZE != 64
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: minor
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: soltys@ziu.info
    Classification: Unclassified


long <type> has always higher rank than <type> even if both have the same
representation. When __WORDSIZE is not 64, SIZE_MAX uses (unsigned int) type in
constant explicitly, but SSIZE_MAX falls back to LONG_MAX which is (long int) -
which is different (higher) rank than (int) or (unsigned int).

Consider following example on 32bit architectures:

#define  _POSIX_SOURCE 1
#include <stdio.h>
#include <limits.h>
#include <sys/types.h>

int main(void)
{
        ssize_t x = 10;
        printf("val: %zd\n", SSIZE_MAX - x);
        return 0;
}

if compiled with gcc -Wall test.c
The compiler will issue warning:

test.c:9: warning: format â%zdâ expects type âsigned size_tâ, but argument 2
has type âlong intâ

So - when __WORDSIZE is not 64 - shouldn't SSIZE_MAX be defined as INT_MAX to
be consistent with SIZE_MAX (the change also fixes warning in the above case) ?

The problem doesn't happen when __WORDSIZE == 64, as in such case types are
(unsigned long int) and (long int) for SIZE_MAX and SSIZE_MAX respectively.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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