This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: Add <limits.h> integer width macros
- From: Florian Weimer <fw at deneb dot enyo dot de>
- To: Joseph Myers <joseph at codesourcery dot com>
- Cc: <libc-alpha at sourceware dot org>
- Date: Sat, 17 Sep 2016 18:55:07 +0200
- Subject: Re: Add <limits.h> integer width macros
- Authentication-results: sourceware.org; auth=none
- References: <alpine.DEB.2.20.1609131749040.9352@digraph.polyomino.org.uk>
* Joseph Myers:
> +That expression includes padding bits as well as value and sign bits.
> +On all systems supported by @theglibc{}, standard integer types do not
> +have any padding bits.
I note that there is no width macro for _Bool, which is included among
the standard integer types (§6.2.5/6: “The type _Bool and the unsigned
integer types […] are the /standard unsigned integer types/.”;
§6.2.5/7: “The standard signed integer types and standard unsigned
integer types are collectively alled the /standard integer types/.”;
emphasis in the original).
Anyway, Bool has padding bits with GCC, so the remark quoted above is
technically wrong. This can be seen with this code
int
f(_Bool *f)
{
return *f & 2;
}
Which compiles to this optimized code with -O2:
f:
xorl %eax, %eax
ret
And to this with -O1:
f:
movzbl (%rdi), %eax
andl $2, %eax
ret
I think that with GCC, _Bool even has representations. Not that I'm
happy about that.