Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

castexpr

Tool

Version

Checker

Description

Compass/ROSE  

Can detect violations of this rule. However, it does not flag explicit casts to void * and then back to another pointer type.

ECLAIRLDRA tool suite

Include Page
LDRAECLAIR_VLDRA
ECLAIR_V

94 Scastexpr540 S

Fully implemented.
EDG   
GCC
Include Page
GCC_V
GCC_V
 

Can detect some violations of this rule when the -Wcast-align flag is used.

EDG   
Compass/ROSE  

Can detect violations of this rule. However, it does not flag explicit casts to void * and then back to another pointer type.

LDRA tool suite

Include Page
LDRA_V
LDRA_V

94 S
540 S

ECLAIR

Include Page
ECLAIR_VECLAIR_VFully implemented.
PRQA QA-C
Include Page
PRQA_V
PRQA_V
3305Fully implemented.

...

For objects declared on the stack, the C standard [ISO/IEC 9899:2011] Standard provides alignas to declare an object to have a stricter alignment. It can be used to resolve the following noncompliant code example.

...

ISO/IEC TR 24772
CERT C++ Secure Coding StandardEXP36-CPP. Do not convert pointers into more strictly aligned pointer types
ISO/IEC TR 24772Pointer casting and pointer type changes [HFC]
ISO/IEC TS 17961(Draft) Converting pointer values to more strictly aligned pointer types [alignconv]Pointer casting and pointer type changes [HFC]
MISRA-CRules Rule 11.2 (required): Conversions shall not be performed between a pointer to object and any type other than an integral type, another pointer to
object type or a pointer to void
Rule 11.3 (advisory): A cast should not be performed between a pointer type and an integral type

Bibliography

...