[...@gnu-6 tmp]$ cat f-1.c struct line { int length; char contents[]; }; void foo (struct line);
struct line bar () { struct line x; x.length = sizeof (struct line); foo (x); return x; } [...@gnu-6 tmp]$ /usr/gcc-4.4/bin/gcc -fno-asynchronous-unwind-tables -O2 -S f-1.c [...@gnu-6 tmp]$ cat f-1.s .file "f-1.c" .text .p2align 4,,15 .globl bar .type bar, @function bar: pushq %rbx movq %rdi, %rbx subq $32, %rsp movl $4, (%rdi) movl $4, (%rsp) call foo movl $4, (%rbx) movq %rbx, %rax addq $32, %rsp popq %rbx ret .size bar, .-bar .ident "GCC: (GNU) 4.4.0 20090317 (experimental) [trunk revision 144915]" .section .note.GNU-stack,"",@progbits [...@gnu-6 tmp]$ cat f-2.c struct line { int length; struct {} c; }; void foo (struct line); struct line bar () { struct line x; x.length = sizeof (struct line); foo (x); return x; } [...@gnu-6 tmp]$ /usr/gcc-4.4/bin/gcc -fno-asynchronous-unwind-tables -O2 -S f-2.c [...@gnu-6 tmp]$ cat f-2.s .file "f-2.c" .text .p2align 4,,15 .globl bar .type bar, @function bar: subq $8, %rsp movl $4, %edi call foo movl $4, %eax addq $8, %rsp ret .size bar, .-bar .ident "GCC: (GNU) 4.4.0 20090317 (experimental) [trunk revision 144915]" .section .note.GNU-stack,"",@progbits [...@gnu-6 tmp]$ -- Summary: structures with zero-length array passed/returned inconsistently Product: gcc Version: 4.4.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target AssignedTo: unassigned at gcc dot gnu dot org ReportedBy: hjl dot tools at gmail dot com GCC target triplet: x86_64-pc-linux-gnu http://gcc.gnu.org/bugzilla/show_bug.cgi?id=39545