This is in C99 Sec. 6.7.2.1 `Structure and union specifiers', clause
13, p. 103, and even in K&R.

If a compiler is doing otherwise, it is violating C.

On Wed, Sep 02, 2026 at 09:08:53AM -0700, ron minnich wrote:
> Thierry, is your comment re the first struct member address aligning to the
> struct address still true in a world in which many C compilers randomize
> struct layout? I'm guessing not.
> 
> 
> On Wed, Sep 2, 2026 at 7:30?AM <[email protected]> wrote:
> 
> > On Wed, Sep 02, 2026 at 10:13:51AM +0200, Shawn Rutledge wrote:
> > >
> > > Lack of shared data structure implementations is one of the main
> > downsides to C.  What?s your favorite workaround?
> > 
> > But since it is a guaranteed that the first member of a structure is
> > at the same address as the structure, one can cast to a shared
> > structure given as the first member of extended or overloaded
> > structures.
> > --
> > Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
> >              http://www.kergis.com/
> >             http://kertex.kergis.com/
> > Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

-- 
        Thierry Laronde <tlaronde +AT+ kergis +dot+ com>
                     http://www.kergis.com/
                    http://kertex.kergis.com/
Key fingerprint = 0FF7 E906 FBAF FE95 FD89  250D 52B1 AE95 6006 F40C

------------------------------------------
9fans: 9fans
Permalink: 
https://9fans.topicbox.com/groups/9fans/Td859d3c6cefc922f-Mad4c16f185a5c7a167378c37
Delivery options: https://9fans.topicbox.com/groups/9fans/subscription

Reply via email to