summaryrefslogtreecommitdiff
path: root/devdocs/gcc~13/structures-unions-enumerations-and-bit-fields-implementation.html
blob: e7301f6cd4729b2bffa77ba98acdeeb1d252b857 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
<div class="section-level-extent" id="Structures-unions-enumerations-and-bit-fields-implementation"> <div class="nav-panel"> <p> Next: <a href="qualifiers-implementation" accesskey="n" rel="next">Qualifiers</a>, Previous: <a href="hints-implementation" accesskey="p" rel="prev">Hints</a>, Up: <a href="c-implementation" accesskey="u" rel="up">C Implementation-Defined Behavior</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div>  <h1 class="section" id="Structures_002c-Unions_002c-Enumerations_002c-and-Bit-Fields"><span>4.9 Structures, Unions, Enumerations, and Bit-Fields<a class="copiable-link" href="#Structures_002c-Unions_002c-Enumerations_002c-and-Bit-Fields"> ¶</a></span></h1> <ul class="itemize mark-bullet"> <li>A member of a union object is accessed using a member of a different type (C90 6.3.2.3). <p>The relevant bytes of the representation of the object are treated as an object of the type used for the access. See <a class="xref" href="optimize-options#Type-punning">Type-punning</a>. This may be a trap representation. </p> </li>
<li>Whether a “plain” <code class="code">int</code> bit-field is treated as a <code class="code">signed int</code> bit-field or as an <code class="code">unsigned int</code> bit-field (C90 6.5.2, C90 6.5.2.1, C99 and C11 6.7.2, C99 and C11 6.7.2.1).  <p>By default it is treated as <code class="code">signed int</code> but this may be changed by the <samp class="option">-funsigned-bitfields</samp> option. </p> </li>
<li>Allowable bit-field types other than <code class="code">_Bool</code>, <code class="code">signed int</code>, and <code class="code">unsigned int</code> (C99 and C11 6.7.2.1). <p>Other integer types, such as <code class="code">long int</code>, and enumerated types are permitted even in strictly conforming mode. </p> </li>
<li>Whether atomic types are permitted for bit-fields (C11 6.7.2.1). <p>Atomic types are not permitted for bit-fields. </p> </li>
<li>Whether a bit-field can straddle a storage-unit boundary (C90 6.5.2.1, C99 and C11 6.7.2.1). <p>Determined by ABI. </p> </li>
<li>The order of allocation of bit-fields within a unit (C90 6.5.2.1, C99 and C11 6.7.2.1). <p>Determined by ABI. </p> </li>
<li>The alignment of non-bit-field members of structures (C90 6.5.2.1, C99 and C11 6.7.2.1). <p>Determined by ABI. </p> </li>
<li>The integer type compatible with each enumerated type (C90 6.5.2.2, C99 and C11 6.7.2.2).  <p>Normally, the type is <code class="code">unsigned int</code> if there are no negative values in the enumeration, otherwise <code class="code">int</code>. If <samp class="option">-fshort-enums</samp> is specified, then if there are negative values it is the first of <code class="code">signed char</code>, <code class="code">short</code> and <code class="code">int</code> that can represent all the values, otherwise it is the first of <code class="code">unsigned char</code>, <code class="code">unsigned short</code> and <code class="code">unsigned int</code> that can represent all the values. </p> <p>On some targets, <samp class="option">-fshort-enums</samp> is the default; this is determined by the ABI. </p> </li>
</ul> </div>  <div class="nav-panel"> <p> Next: <a href="qualifiers-implementation">Qualifiers</a>, Previous: <a href="hints-implementation">Hints</a>, Up: <a href="c-implementation">C Implementation-Defined Behavior</a> [<a href="index#SEC_Contents" title="Table of contents" rel="contents">Contents</a>][<a href="indices" title="Index" rel="index">Index</a>]</p> </div><div class="_attribution">
  <p class="_attribution-p">
    &copy; Free Software Foundation<br>Licensed under the GNU Free Documentation License, Version 1.3.<br>
    <a href="https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Structures-unions-enumerations-and-bit-fields-implementation.html" class="_attribution-link">https://gcc.gnu.org/onlinedocs/gcc-13.1.0/gcc/Structures-unions-enumerations-and-bit-fields-implementation.html</a>
  </p>
</div>