tech-kern archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: in which we present an ugly hack to make sys/queue.h CIRCLEQ work

> [The compiler] also couldn't know if pointers whose types it did know
> were referring to different members of the same union, perhaps with
> the union declared in another compilation unit

The text I have says

       [#5]  One special guarantee is made in order to simplify the
       use of unions: if a union contains several  structures  that
       share  a  common  initial  sequence  (see below), and if the
       union object currently contains one of these structures,  it
       is  permitted  to  inspect the common initial part of any of
       them anywhere that a declaration of the  completed  type  of
       the union is visible.  Two structures share a common initial
       sequence if  corresponding  members  have  compatible  types
       (and, for bit-fields, the same widths) for a sequence of one
       or more initial members.

Note that the completed union declaration must be visible for this
exemption to apply, so as I read it the part after the last comma of
the quote I opened this mail with is wrong....

> in which case not only would it be valid for the pointers to refer to
> the same object but it wouldn't violate the aliasing rules to access
> compatibly typed members at the start of each structure with the
> different pointers (that's another bit the standard allows and the
> aliasing rules don't prohibit).

As I read it, the aliasing rule does prohibit it, but may be overridden
by another rule; the question is whether #5 (the [#5] above)
overrides 6.5 #7 (the anti-alias rule quoted upthread).  (My own guess
would be that it does.)

/~\ The ASCII                             Mouse
\ / Ribbon Campaign
 X  Against HTML      
/ \ Email!           7D C8 61 52 5D E7 2D 39  4E F1 31 3E E8 B3 27 4B

Home | Main Index | Thread Index | Old Index