forked from boostorg/endian
Add recommendation to protect against assignment ills, with example.
This commit is contained in:
@ -346,7 +346,12 @@ Code that uses a</span>ligned types is possibly non-portable because alignment
|
|||||||
requirements vary between hardware architectures and because alignment may be
|
requirements vary between hardware architectures and because alignment may be
|
||||||
affected by compiler switches or pragmas. For example, alignment of an 64-bit
|
affected by compiler switches or pragmas. For example, alignment of an 64-bit
|
||||||
integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types
|
integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types
|
||||||
are only available on architectures with 16, 32, and 64-bit integer types. </p>
|
are only available on architectures with 16, 32, and 64-bit integer types.</p>
|
||||||
|
<p><i><b>Recommendation:</b></i> Protect yourself against alignment ills. For
|
||||||
|
example:</p>
|
||||||
|
<blockquote>
|
||||||
|
<pre>static_assert(sizeof(containing_struct) == 12, "sizeof(containing_struct) is wrong"); </pre>
|
||||||
|
</blockquote>
|
||||||
<p><b><i>Note:</i></b> One-byte types
|
<p><b><i>Note:</i></b> One-byte types
|
||||||
have identical
|
have identical
|
||||||
functionality. They are provided to improve code readability and searchability.</p>
|
functionality. They are provided to improve code readability and searchability.</p>
|
||||||
@ -677,7 +682,7 @@ differs from endian representation size. Vicente Botet and other reviewers
|
|||||||
suggested supporting floating point types.</p>
|
suggested supporting floating point types.</p>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Last revised:
|
<p>Last revised:
|
||||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->19 January, 2015<!--webbot bot="Timestamp" endspan i-checksum="38903" --></p>
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 January, 2015<!--webbot bot="Timestamp" endspan i-checksum="38896" --></p>
|
||||||
<p>© Copyright Beman Dawes, 2006-2009, 2013</p>
|
<p>© Copyright Beman Dawes, 2006-2009, 2013</p>
|
||||||
<p>Distributed under the Boost Software License, Version 1.0. See
|
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||||
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
|
||||||
|
@ -334,6 +334,11 @@ requirements vary between hardware architectures and because alignment may be
|
|||||||
affected by compiler switches or pragmas. For example, alignment of an 64-bit
|
affected by compiler switches or pragmas. For example, alignment of an 64-bit
|
||||||
integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types
|
integer may be to a 32-bit boundary on a 32-bit machine. Furthermore, aligned types
|
||||||
are only available on architectures with 16, 32, and 64-bit integer types. </p>
|
are only available on architectures with 16, 32, and 64-bit integer types. </p>
|
||||||
|
<p><i><b>Recommendation:</b></i> Protect yourself against alignment ills. For
|
||||||
|
example:</p>
|
||||||
|
<blockquote>
|
||||||
|
<pre>static_assert(sizeof(containing_struct) == 12, "sizeof(containing_struct) is wrong"); </pre>
|
||||||
|
</blockquote>
|
||||||
<p><b><i>Note:</i></b> One-byte big and little buffer types
|
<p><b><i>Note:</i></b> One-byte big and little buffer types
|
||||||
have identical
|
have identical
|
||||||
functionality. They are provided to improve code readability and searchability.</p>
|
functionality. They are provided to improve code readability and searchability.</p>
|
||||||
@ -650,7 +655,7 @@ any Boost object libraries.</p>
|
|||||||
</ul>
|
</ul>
|
||||||
<hr>
|
<hr>
|
||||||
<p>Last revised:
|
<p>Last revised:
|
||||||
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->19 January, 2015<!--webbot bot="Timestamp" endspan i-checksum="38903" --></p>
|
<!--webbot bot="Timestamp" s-type="EDITED" s-format="%d %B, %Y" startspan -->25 January, 2015<!--webbot bot="Timestamp" endspan i-checksum="38896" --></p>
|
||||||
<p>© Copyright Beman Dawes, 2006-2009, 2013</p>
|
<p>© Copyright Beman Dawes, 2006-2009, 2013</p>
|
||||||
<p>Distributed under the Boost Software License, Version 1.0. See
|
<p>Distributed under the Boost Software License, Version 1.0. See
|
||||||
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
|
<a href="http://www.boost.org/LICENSE_1_0.txt">www.boost.org/ LICENSE_1_0.txt</a></p>
|
||||||
|
Reference in New Issue
Block a user