Add <limits.h> integer width macros

Florian Weimer fw@deneb.enyo.de
Sat Sep 17 16:55:00 GMT 2016


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



More information about the Libc-alpha mailing list