Article View: comp.std.c
Article #3315Re: Structure walking
From: Norman Diamond
Date: Wed, 27 Jan 1993 01:46
Date: Wed, 27 Jan 1993 01:46
41 lines
2767 bytes
2767 bytes
In article <565@heimdall.sdrc.com> scjones@thor.sdrc.com (Larry Jones) writes:
>In article <1993Jan25.213543.25499@pony.Ingres.COM>, mikes@Ingres.COM (Mike Schilling) writes:
>> (e) The alignment required by the structure is equal to the most restrictive
>> alignment of any of its members.
>True, but see (a).
Well Mr. Jones, you and I seem to be the only people who feel this way.
Most of the regulars in this group felt that even a structure like this:
struct mychar { char x; }
might be given an alignment requirement of 32 by some compiler, even if
char only requires an alignment of 1 under the same compiler. Of course,
I only saw this on Usenet; you've seen the committee's deliberations.
>> (f) The size of the structure is the offset of the last member of the structure,
>> plus the size of the last member, rounded up to alignment required
>> by the structure.
>False. ANSI 3.5.2.1 again:
> There may also be unnamed padding at the end of a structure or
> union, as necessary to achieve the *appropriate* alignment were
> the structure or union to be an element of an array.
>Again, it says "appropriate", not "required".
Now I don't understand. Strictly speaking, the alignment of each member
was already a matter of appropriateness rather than requirement, because
no alignment is really required. It is always possible to bit-align a
float but do lots of byte moves and integral shifts to move the float into
a temporary location properly aligned for a hardware operation.
So, an appropriate alignment for a structure is equal to the most
restrictive appropriate alignment of any of its members, right?
Then, how can the unnamed padding at the end, as NECESSARY to achieve
appropriate alignment were it an array member, be any different from
Mr. Schilling's computation?
I think that the answer to (f) cannot differ from the answer to (e).
--
Norman Diamond diamond@jit.dec.com
If this were the company's opinion, I wouldn't be allowed to post it.
Pardon me? Or do I have to commit a crime first?
Technical Details
Message-ID:
<1993Jan27.014643.21507@nntpd.lkg.dec.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!gatech!swrinde!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!usenet.coe.montana.edu!decwrl!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamondReferences:
<1993Jan25.213543.25499@pony.Ingres.COM> <565@heimdall.sdrc.com>Show Full Headers
Complete Article Headers
Newsgroups: comp.std.c Path: arc1-ca.pugleaf.net!sparky!uunet!ferkel.ucsb.edu!taco!gatech!swrinde!zaphod.mps.ohio-state.edu!saimiri.primate.wisc.edu!usenet.coe.montana.edu!decwrl!pa.dec.com!engage.pko.dec.com!nntpd.lkg.dec.com!jit345.bad.jit.dec.com!diamond From: diamond@jit345.bad.jit.dec.com (Norman Diamond) Subject: Re: Structure walking Message-ID: <1993Jan27.014643.21507@nntpd.lkg.dec.com> Sender: usenet@nntpd.lkg.dec.com (USENET News System) Reply-To: diamond@jit.dec.com (Norman Diamond) Organization: Digital Equipment Corporation Japan , Tokyo References: <1993Jan25.213543.25499@pony.Ingres.COM> <565@heimdall.sdrc.com> Date: Wed, 27 Jan 1993 01:46:43 GMT Lines: 41