dlr bug
[mcs.git] / docs / ecma334 / 25.5.8.xml
blob242bda31ce657c0ae08b3bcc0d3bdec67b685760
1 <?xml version="1.0"?>
2 <clause number="25.5.8" title="The sizeof operator">
3   <paragraph>The sizeof operator returns the number of bytes occupied by a variable of a given type. The type specified as an operand to sizeof must be an <non_terminal where="25.2">unmanaged-type</non_terminal> (<hyperlink>25.2</hyperlink>). <grammar_production><name><non_terminal where="25.5.8">sizeof-expression</non_terminal></name> : <rhs><keyword>sizeof</keyword><terminal>(</terminal><non_terminal where="25.2">unmanaged-type</non_terminal><terminal>)</terminal></rhs></grammar_production></paragraph>
4   <paragraph>The result of the sizeof operator is a value of type <keyword>int</keyword>. For certain predefined types, the sizeof operator yields a constant value as shown in the table below. <table_line>Expression Result </table_line>
5 <table_line>sizeof(<keyword>sbyte</keyword>) 1 </table_line>
6 <table_line>sizeof(<keyword>byte</keyword>) 1 </table_line>
7 <table_line>sizeof(<keyword>short</keyword>) 2 </table_line>
8 <table_line>sizeof(<keyword>ushort</keyword>) 2 </table_line>
9 <table_line>sizeof(<keyword>int</keyword>) 4 </table_line>
10 <table_line>sizeof(<keyword>uint</keyword>) 4 </table_line>
11 <table_line>sizeof(<keyword>long</keyword>) 8 </table_line>
12 <table_line>sizeof(<keyword>ulong</keyword>) 8 </table_line>
13 <table_line>sizeof(<keyword>char</keyword>) 2 </table_line>
14 <table_line>sizeof(<keyword>float</keyword>) 4 </table_line>
15 <table_line>sizeof(<keyword>double</keyword>) 8 </table_line>
16 <table_line>sizeof(<keyword>bool</keyword>) 1 </table_line>
17 </paragraph>
18   <paragraph>For all other types, the result of the sizeof operator is implementation-defined and is classified as a value, not a constant. </paragraph>
19   <paragraph>The order in which members are packed into a struct is unspecified. </paragraph>
20   <paragraph>For alignment purposes, there may be unnamed padding at the beginning of a struct, within a struct, and at the end of the struct. The contents of the bits used as padding are indeterminate. </paragraph>
21   <paragraph>When applied to an operand that has struct type, the result is the total number of bytes in a variable of that type, including any padding. </paragraph>
22 </clause>