Hi,

On Tue, 8 Dec 2009, H.J. Lu wrote:

> Both icc and gcc generate:
> 
> [...@gnu-26 pr42324]$ cat b4.c
> extern unsigned int bartmp;
> 
> void foo(_Bool bar)
> {
>  bartmp = bar;
> }
> [...@gnu-26 pr42324]$ /usr/gcc-4.4/bin/gcc -O2 b4.c -S
> [...@gnu-26 pr42324]$ cat b4.s
>       .file   "b4.c"
>       .text
>       .p2align 4,,15
> .globl foo
>       .type   foo, @function
> foo:
> .LFB2:
>       movzbl  %dil, %edi
>       movl    %edi, bartmp(%rip)
>       ret

Yes, so they expect the upper bits (at least 1-7) cleared on the caller 
side.  And if they do that, somebody needs to make this guarantee which 
only the ABI can.

> We should just drop
> 
> ---
> When a value of type _Bool is passed in a register or on the stack,
> the upper 63 bits of the eightbyte shall be zero.
> ---

If anything we can only change it to say something less strict ...

> from psABI. Since _Bool has one byte in size with values of 0 and 1.
> Compilers have to clear upper 7 bits in one byte.

... because this part can only be guaranteed by the ABI.  Without the 
above language a compiler would be free to implement any non-zero byte as 
true for parameter passing without violating the ABI.


Ciao,
Michael.

Reply via email to