This is the mail archive of the libc-alpha@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]

Re: Add <limits.h> integer width macros


* 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.


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