This is the mail archive of the gcc-bugs@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]

__attribute__ ((packed)) broken?



Hi All,

  In the latest CVS version, GCC appears to be ignoring the
"__attribute__ ((packed))" as applied to a structure.  I have created a
simple test case and the output from CVS 20000826 (which is correct)
and CVS 20000918 (which is not).  GCC is being built with
"--enable-c-cpplib" in the CVS 20000918 case but not the CVS
20000826 case.  I a sure that the "--enable-c-cpplib" is not the cause 
as I have in the past couple weeks built versions of GCC with
"--enable-c-cpplib" that handle the "__attribute__ ((packed))" correctly.

--- t.c ---

typedef struct s {
	unsigned short 	a	__attribute__ ((packed));
	unsigned int	b	__attribute__ ((packed));
} s				__attribute__ ((packed));


void
f(void)
{
	s	a;

	a.b = 0x12345678;
}

----------

 
--- good.s ---
@ Generated by gcc 2.96 20000826 (experimental) for ARM/elf
	.file	"t.c"
.gcc2_compiled.:
.text
	.align	2
	.global	f
	.type	 f,function
f:
	@ args = 0, pretend = 0, frame = 12
	@ frame_needed = 1, current_function_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {fp, ip, lr, pc}
	sub	fp, ip, #4
	sub	sp, sp, #12
	mov	r3, #0
	orr	r3, r3, #22016
	orr	r3, r3, #120
	strh	r3, [fp, #-18]	@ movhi 
	mov	r3, #0
	orr	r3, r3, #4608
	orr	r3, r3, #52
	strh	r3, [fp, #-16]	@ movhi 
	ldmea	fp, {fp, sp, pc}
.Lfe1:
	.size	 f,.Lfe1-f

----------

--- bad.s ---

@ Generated by gcc 2.96 20000918 (experimental) for ARM/elf
	.file	"t.c"
.gcc2_compiled.:
.text
	.align	2
	.global	f
	.type	 f,function
f:
	@ args = 0, pretend = 0, frame = 8
	@ frame_needed = 1, current_function_anonymous_args = 0
	mov	ip, sp
	stmfd	sp!, {fp, ip, lr, pc}
	sub	fp, ip, #4
	sub	sp, sp, #8
	ldr	r3, .L3
	str	r3, [fp, #-18]		<= unaligned store traps !
	ldmea	fp, {fp, sp, pc}
.L4:
	.align	2
.L3:
	.word	305419896
.Lfe1:
	.size	 f,.Lfe1-f

-----------

	Thanks,

		CraigN
--
      Craig Newell                email: CraigN@ieee.org
      Free Spirit                 icbm:  N 42°38'47" W 71°18'19"



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