Article View: comp.std.c
Article #148Re: Character arrays in structures and address alignment -- any standard?
From: Christopher R Volpe
Date: Wed, 29 Jul 1992 12:40
Date: Wed, 29 Jul 1992 12:40
39 lines
2234 bytes
2234 bytes
In article <14235@ksr.com>, jfw@ksr.com (John F. Woods) writes: |> restriction or requirement is met. For example, it was claimed at one time |> that, although the Standard lists two and only two kinds of null pointer |> constants (an integral constant zero or an integral constant zero cast to |> void *), a compiler could make NULL expand into (char *)0, because a strictly |> conforming program couldn't tell the difference. Doug Gwyn (I think) then |> demonstrated one that could, taking advantage of the # operator. I believe that was me, not Doug. |> What the standard says about alignment of things in a structure is: |> |> "Each non-bit-field member of a structure or union object is aligned |> in an implementation-defined manner appropriate to its type." |> |> An implementation must document its strategy, but |> |> "For all types, structure members are aligned on 16-byte boundaries, |> except on Fat Tuesday and Christmas, when for all types, structure |> members are aligned on 64-byte boundaries for good luck." I guess we've exhausted all creative examples of undefined behavior, so we're moving on to implementation-defined behavior :). I love it! |> |> is perfectly acceptable, even if everything is addressable on arbitrary byte |> boundaries. If you would quibble with whether that is "appropriate", either |> write a SCP that exposes the error, or chalk it up to "quality of |> implementation". I would agree with that. -Chris -- ================== Chris Volpe G.E. Corporate R&D volpecr@crd.ge.com
Technical Details
Message-ID:
<1992Jul29.124005.22841@crd.ge.com>Path:
arc1-ca.pugleaf.net!sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpeReferences:
<1992Jul26.225252.4487@anasazi.com> <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <bs3x0j.ilr@wang.com> <14235@ksr.com>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!crdgw1!rdsunx.crd.ge.com!bart!volpe From: volpe@bart.NoSubdomain.NoDomain (Christopher R Volpe) Newsgroups: comp.std.c Subject: Re: Character arrays in structures and address alignment -- any standard? Message-ID: <1992Jul29.124005.22841@crd.ge.com> Date: 29 Jul 92 12:40:05 GMT References: <1992Jul26.225252.4487@anasazi.com> <1992Jul27.183622.794@taumet.com> <1992Jul28.063356.28005@sq.sq.com> <14216@ksr.com> <bs3x0j.ilr@wang.com> <14235@ksr.com> Sender: volpe@bart (Christopher R Volpe) Reply-To: volpe@ausable.crd.ge.com Organization: GE Corporate Research & Development Lines: 39 Nntp-Posting-Host: bart.crd.ge.com