Re: Warning: The structure contains misaligned fields



Steve Lionel wrote:
On Mon, 28 Apr 2008 11:06:45 -0800, glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
wrote:

I thought that padding was allowed, though. COMMON in Fortran 66
was usually believed not to allow padding, creating alignment
problems fairly often. C struct definitely allows padding, which
is good because many current processors don't allow misaligned
access. (IA32 does, but it is often much slower.)
Doesn't COMMON now allow for padding?

Only to the length of a "storage unit" if you still want to meet
the letter of the standard.

So anything smaller can be padded, but no padding for items
larger than a "storage unit."

So the old rule of double precision variables first should
still work.

-- glen

.



Relevant Pages

  • Re: Data alignment problems with sizeof and new
    ... >I have a strange problem with a project involving classes with data alignment ... It appears that, in this particular project, the sizeof and new ... >operators are not taking the alignment padding into account when calculating ... >class with the first member being a dword size followed by doubles, ...
    (microsoft.public.vc.language)
  • Data alignment problems with sizeof and new
    ... I have a strange problem with a project involving classes with data alignment ... It appears that, in this particular project, the sizeof and new ... operators are not taking the alignment padding into account when calculating ... class with the first member being a dword size followed by doubles, ...
    (microsoft.public.vc.language)
  • Re: [PATCH] block: fix residual byte count handling
    ... Are you suggesting moving them back to drivers? ... with adjusting sglist entries in the block layer with your secode ... patch (separate out padding from alignment). ...
    (Linux-Kernel)
  • Re: [JW] alignment problem for structures
    ... Is that enough to make the alignment requirements apply to ... Array elements include interelement ... >> alignment padding. ... to the start of the struct, then the assignment to *q1 will not "work". ...
    (comp.std.c)
  • Re: UDT memory alignment
    ... Probably the simplest way to look at this, is instead of calling it "dword ... the alignment is such that the whole ... positioned at an alignment that is a multiple of it's length, ... they can be placed without the need for preceding padding. ...
    (microsoft.public.vb.general.discussion)