AutosarC++19_03-M5.2.6¶
A cast shall not convert a pointer to a function to any other pointer type, including a pointer to function type
Required inputs: IR
| Level | required |
|---|---|
| Target | implementation |
| Enforcement | automated |
[Undefined 5.2.10(6), Unspecified 5.2.10(6)]
Rationale
Conversion of a function pointer to a non-function pointer type causes undefined behaviour.
Undefined behaviour may arise if a function call is made using a pointer that is the result of a function pointer conversion.
Example
void f ( int32_t )
{
reinterpret_cast< void (*)( ) >( &f ); // Non-compliant
reinterpret_cast< void * >( &f ); // Non-compliant
}
Note
For legal reasons, this rule’s description is not part of the public documentation.