Re: Subtleties of __attribute__((packed))

2006-12-07 Thread Andreas Schwab
Jan Blunck <[EMAIL PROTECTED]> writes: > Once again: I refered to "packed attribute on the struct vs. packed attribute > on each member of the struct". The alignment shouldn't be different. You are mistaken. The alignment of a non-packed structure can be greater than the maximum alignment of the

Re: Subtleties of __attribute__((packed))

2006-12-07 Thread Jan Blunck
On Wed, Dec 06, Russell King wrote: > On Wed, Dec 06, 2006 at 04:54:39PM +0100, Jan Blunck wrote: > > Maybe the arm backend is somehow broken. AFAIK (and I verfied it on S390 and > > i386) the alignment shouldn't change. > Once again: I refered to "packed attribute on the struct vs. packed attri

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread David Miller
From: Russell King <[EMAIL PROTECTED]> Date: Wed, 6 Dec 2006 17:54:23 + > It does not say "and as such the struct may be aligned to any alignment". Consider the implication for arrays and pointer arithmetic, it's just a logical consequence, that's all. It's why the alignment cannot be assume

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Russell King
On Wed, Dec 06, 2006 at 04:54:39PM +0100, Jan Blunck wrote: > Maybe the arm backend is somehow broken. AFAIK (and I verfied it on S390 and > i386) the alignment shouldn't change. Please read the info pages: `packed' This attribute, attached to an `enum', `struct', or `union' type defini

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Andreas Schwab
Jan Blunck <[EMAIL PROTECTED]> writes: > Well, right ... and where do you see a structure of packed members? Read . Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germa

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Jan Blunck
On Wed, Dec 06, Andreas Schwab wrote: > Jan Blunck <[EMAIL PROTECTED]> writes: > > > Maybe the arm backend is somehow broken. > > A packed structure is something quite different than a structure of packed > members. > Well, right ... and where do you see a structure of packed members? http://

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Jan Blunck
On Wed, Dec 06, Phil Endecott wrote: > > To see a difference with your example structs you need to compare these two: > > struct wibble1 { > char c; > struct bar1 b1; > }; > > struct wibble2 { > char c; > struct bar2 b2; > }; > > struct wibble1 w1 = { 1, { 2, {3,4,5} } }; > struct wibb

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Phil Endecott
Jan Blunk wrote: Maybe the arm backend is somehow broken. AFAIK (and I verfied it on S390 and i386) the alignment shouldn't change. To see a difference with your example structs you need to compare these two: struct wibble1 { char c; struct bar1 b1; }; struct wibble2 { char c; struct

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Andreas Schwab
Jan Blunck <[EMAIL PROTECTED]> writes: > Maybe the arm backend is somehow broken. A packed structure is something quite different than a structure of packed members. Andreas. -- Andreas Schwab, SuSE Labs, [EMAIL PROTECTED] SuSE Linux Products GmbH, Maxfeldstraße 5, 90409 Nürnberg, Germany PGP

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Jan Blunck
On Wed, Dec 06, Phil Endecott wrote: > I don't think so. Example: > > struct test { > int a __attribute__((packed)); > int b __attribute__((packed)); > }; > > char c = 1; > struct test t = { .a=2, .b=3 }; > > $ arm-linux-gnu-gcc -O2 -S -W -Wall test1.c > > .file "test2.c" >

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Phil Endecott
Jan Blunck wrote: On 12/6/06, Phil Endecott <[EMAIL PROTECTED]> wrote: I used to think that this: struct foo { int a __attribute__((packed)); char b __attribute__((packed)); ... more fields, all packed ... }; was exactly the same as this: struct foo { int a; char b; ... mor

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Jan Blunck
On 12/6/06, Phil Endecott <[EMAIL PROTECTED]> wrote: Dear All, I used to think that this: struct foo { int a __attribute__((packed)); char b __attribute__((packed)); ... more fields, all packed ... }; was exactly the same as this: struct foo { int a; char b; ... more fields

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Phil Endecott
Frederik Deweerdt wrote: On Wed, Dec 06, 2006 at 01:20:41PM +, Phil Endecott wrote: I used to think that this: struct foo { int a __attribute__((packed)); char b __attribute__((packed)); ... more fields, all packed ... }; was exactly the same as this: struct foo { int a; char b

Re: Subtleties of __attribute__((packed))

2006-12-06 Thread Frederik Deweerdt
On Wed, Dec 06, 2006 at 01:20:41PM +, Phil Endecott wrote: > Dear All, > > I used to think that this: > > struct foo { > int a __attribute__((packed)); > char b __attribute__((packed)); > ... more fields, all packed ... > }; > > was exactly the same as this: > > struct foo { > int

Subtleties of __attribute__((packed))

2006-12-06 Thread Phil Endecott
Dear All, I used to think that this: struct foo { int a __attribute__((packed)); char b __attribute__((packed)); ... more fields, all packed ... }; was exactly the same as this: struct foo { int a; char b; ... more fields ... } __attribute__((packed)); but it is not, in a subtle