This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC 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: Bug in x86-64 psABI or in gcc?


On Wed, Dec 9, 2009 at 2:04 AM, Michael Matz <matz@suse.de> wrote:
> Hi,
>
> On Tue, 8 Dec 2009, H.J. Lu wrote:
>
>> Both icc and gcc generate:
>>
>> [hjl@gnu-26 pr42324]$ cat b4.c
>> extern unsigned int bartmp;
>>
>> void foo(_Bool bar)
>> {
>> ?bartmp = bar;
>> }
>> [hjl@gnu-26 pr42324]$ /usr/gcc-4.4/bin/gcc -O2 b4.c -S
>> [hjl@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.
>

Aren't bits in the _Bool byte of"bar" specified by the psABI or the C
language standard already?

---
extern unsigned int bartmp;
extern _Bool bar;

void foo()
{
 bartmp = bar;
}
---

Why should the _Bool byte in "void foo(_Bool bar)"  be any different?

-- 
H.J.


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