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 11:47:51 +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
--- Comment #5 from Eric Blake <eblake at redhat dot com> ---
(In reply to joseph@codesourcery.com from comment #1)
> There is no guarantee that ssize_t is the signed type corresponding to
> size_t - and you can't safely change types between int and long because
> that would change the C++ name mangling.
Correct - it is not portable to assume that %zd maps to ssize_t. In fact, there
is NO portable way to print an ssize_t value through printf() without a cast.
But we aren't talking about portability, but about glibc - and in glibc, we can
take extra care to make sure size_t and ssize_t are the same type, if the
system didn't decide otherwise.
But just because warnings on %zd are insufficient to prove whether there is a
bug does not make it any less a bug. If glibc knows that ssize_t is an int
(regardless of whether size_t is an unsigned int or unsigned long), then
SSIZE_MAX must also be an expression of type int. And in C++, with function
overloading, this matters, if I want foo(SSIZE_MAX) to call the correct
overload.
--
You are receiving this mail because:
You are on the CC list for the bug.