Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The behavior of type punning with union changed from C89 to C99. The behavior in C99 is the same as C11.</p> <p>As <a href="https://stackoverflow.com/a/11639995/1119701">Wug</a> noted in his answer, type punning is allowed in C99 / C11. An unspecified value that could be a trap is read when the union members are of different size.</p> <p>The footnote was added in C99 after Clive D.W. Feather <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_257.htm" rel="noreferrer">Defect Report #257</a>:</p> <blockquote> <p><strong>Finally, one of the changes from C90 to C99 was to remove any restriction on accessing one member of a union when the last store was to a different one.</strong> The rationale was that the behaviour would then depend on the representations of the values. Since this point is often misunderstood, it might well be worth making it clear in the Standard.</p> <p>[...]</p> <p>To address the issue about "type punning", attach a new footnote 78a to the words "named member" in 6.5.2.3#3: 78a If the member used to access the contents of a union object is not the same as the member last used to store a value in the object, the appropriate part of the object representation of the value is reinterpreted as an object representation in the new type as described in 6.2.6 (a process sometimes called "type punning"). This might be a trap representation.</p> </blockquote> <p>The wording of Clive D.W. Feather was accepted for a Technical Corrigendum in the answer by the C Committee for <a href="http://www.open-std.org/jtc1/sc22/wg14/www/docs/dr_283.htm" rel="noreferrer">Defect Report #283</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload