[Bug middle-end/24969] tmpdir-gcc.dg-struct-layout-1/t026 fails execution
--- Comment #4 from rguenth at gcc dot gnu dot org 2005-11-21 13:40 --- Old value = 0 New value = 1 check2495 (arg0={a = 27121, b = {c = {d = true, e = 359101392}}}, arg1=0x5019ec, arg2={a = 30216, b = {c = {d = true, e = 1}}}) at t026_y.min.i:71 71 if (arg2.b.c.e != a2495[2].b.c.e) ++fails; Reduced testcase: void abort(void); struct S2495 { short int a; union{ struct{ _Bool d; int e:31; } c; } b; }; struct S2495 x; void foo(struct S2495 a) __attribute__((noinline)); void foo(struct S2495 a) { if (a.a != x.a) abort(); if (a.b.c.d != x.b.c.d) abort(); if (a.b.c.e != x.b.c.e) abort(); } int main() { x.a = 30216; x.b.c.d = 1; x.b.c.e = 32766; foo(x); return 0; } -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24969
[Bug middle-end/24969] tmpdir-gcc.dg-struct-layout-1/t026 fails execution
--- Comment #5 from rguenth at gcc dot gnu dot org 2005-11-21 14:06 --- Disassembly with the first two checks removed (only the third aborts): foo: .LFB2: subq$24, %rsp #, .LCFI0: movlx+8(%rip), %eax #, tmp62 movl16(%rsp), %edx #, tmp60 movq%rdi, 8(%rsp) # a, a andl$2147483647, %eax #, tmp62 andl$2147483647, %edx #, tmp60 cmpl%eax, %edx # tmp62, tmp60 jne .L6 #, addq$24, %rsp #, ret .L6: callabort # main: .LFB3: subq$8, %rsp#, .LCFI1: movlx+8(%rip), %eax #, tmp62 movw$30216, x(%rip) #, x.a movb$1, x+4(%rip) #, x.b.c.d movqx(%rip), %rdi # x, x andl$-2147483648, %eax #, tmp62 orl $32766, %eax#, tmp62 movl%eax, x+8(%rip) # tmp62, callfoo # xorl%eax, %eax # result addq$8, %rsp#, ret it looks like we are confused on where we passed the structure by value. It's in %rdi and %eax, while we think it got passed on stack(!?) in foo. Someone with more x86_64 ABI knowledge has to look into this. -- rguenth at gcc dot gnu dot org changed: What|Removed |Added CC||hubicka at gcc dot gnu dot ||org http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24969
[Bug middle-end/24969] tmpdir-gcc.dg-struct-layout-1/t026 fails execution
--- Comment #6 from matz at suse dot de 2005-11-21 14:25 --- Something is fishy. Iff registers are used for passing then it would have to be %rdi and %rsi (not %rax)! So the high part of this struct (where the bitfield lies) is not passed at all here. Per ABI this whole struct should be passed in registers (it's not larger than two eightbytes, and both eightbytes have class INTEGER (they contain no unaligned fields or other fancy stuff)). -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24969