This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug libc/13575] SSIZE_MAX defined as LONG_MAX is inconsistent with SIZE_MAX, when __WORDSIZE != 64
- From: "eblake at redhat dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Tue, 12 Jul 2016 17:05:36 +0000
- Subject: [Bug libc/13575] SSIZE_MAX defined as LONG_MAX is inconsistent with SIZE_MAX, when __WORDSIZE != 64
- Auto-submitted: auto-generated
- References: <bug-13575-131@http.sourceware.org/bugzilla/>
https://sourceware.org/bugzilla/show_bug.cgi?id=13575
Eric Blake <eblake at redhat dot com> changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|RESOLVED |REOPENED
CC| |eblake at redhat dot com
Resolution|INVALID |---
--- Comment #4 from Eric Blake <eblake at redhat dot com> ---
Reopening this. The bug is clearly glibc's:
$ grep SSIZE_MAX /usr/include/bits/posix1_lim.h
#define _POSIX_SSIZE_MAX 32767
#ifndef SSIZE_MAX
# define SSIZE_MAX LONG_MAX
$ rpm -qf /usr/include/bits/posix1_lim.h
glibc-headers-2.22-17.fc23.x86_64
$ printf '#include <limits.h>\n#include <sys/types.h>\nssize_t a =
SSIZE_MAX;\n'\
| gcc -E - | grep size_t
__extension__ typedef long int __blksize_t;
__extension__ typedef int __ssize_t;
typedef __ssize_t ssize_t;
typedef unsigned int size_t;
typedef __blksize_t blksize_t;
ssize_t a = 0x7fffffffL;
and compare these words from POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html#tag_13_24
"Numerical Limits
The <limits.h> header shall define the following macros and, except for
{CHAR_BIT}, {LONG_BIT}, {MB_LEN_MAX}, and {WORD_BIT}, they shall be replaced by
expressions that have the same type as would an expression that is an object of
the corresponding type converted according to the integer promotions."
Given the above grep, the integer promotion of an ssize_t value is still int,
not long int, so the glibc header is wrong for blindly using LONG_MAX as the
definition of SSIZE_MAX.
--
You are receiving this mail because:
You are on the CC list for the bug.