...
Code Block | ||||
---|---|---|---|---|
| ||||
struct timer { unsigned char MODE; unsigned int DATA; unsigned int COUNT; }; #if (sizeof(struct timer) =!= (sizeof(unsigned char) + sizeof(unsigned int) + sizeof(unsigned int))) #error "Structure must not have any padding" #endif |
...
Search for vulnerabilities resulting from the violation of this rule on the CERT website.
Related Guidelines
C++ Secure Coding Standard | DCL03-CPP. Use a static assertion to test the value of a constant expression |
Bibliography
[Becker 2008] | |
[Eckel 2007] | |
[ISO/IEC 9899:2011] | Section 6.7.10, "Static Assertions" |
[Jones 2010] | |
[Klarer 2004] | |
[Saks 2005] | |
[Saks 2008] |
...