...
On the same platform, this solution produces the expected output of:
Code Block |
---|
int is 0, float is 0.000000 int is 1, float is 1.000000 |
...
Consider the following structure made up of four 8-bit bit-field members.:
Code Block |
---|
struct bf { unsigned int m1 : 8; unsigned int m2 : 8; unsigned int m3 : 8; unsigned int m4 : 8; }; /* 32 bits total */ |
...
The following code behaves differently depending on whether the implementation is left-to-right or right-to-left.:
Code Block | ||
---|---|---|
| ||
struct bf { unsigned int m1 : 8; unsigned int m2 : 8; unsigned int m3 : 8; unsigned int m4 : 8; }; /* 32 bits total */ void function() { struct bf data; unsigned char *ptr; data.m1 = 0; data.m2 = 0; data.m3 = 0; data.m4 = 0; ptr = (unsigned char *)&data; (*ptr)++; /* can increment data.m1 or data.m4 */ } |
...
Tool | Version | Checker | Description | ||||
---|---|---|---|---|---|---|---|
|
|
|
|
...
Search for vulnerabilities resulting from the violation of this recommendation on the CERT website.
Related Guidelines
CERT C++ Secure Coding Standard: EXP11-CPP. Do not apply operators expecting one type to data of an incompatible type
...
\[[ISO/IEC 9899:1999|AA. Bibliography#ISO/IEC 9899-1999]\] Section 6.7.2, "Type specifiers"
\[[ Wiki Markup
ISO/IEC PDTR 24772|AA. Bibliography#ISO/IEC PDTR 24772]\] TR 24772 "STR Bit Representations"
MISRA Rule 3.5
Bibliography
Wiki Markup |
---|
\[[MISRA 2004|AA. Bibliography#MISRA 04]\] Rule 3.5
\[[Plum 1985|AA. Bibliography#Plum 85]\] Rule 6-5 |
...