C and C++


LANG.CAST.VARARG : Varargs Function Cast

Summary

A varargs function pointer is cast to another function pointer that has different parameters or return type.

Properties

Class Name Varargs Function Cast
Significance security
Mnemonic LANG.CAST.VARARG
Categories
AUTOSARC++14 AUTOSARC++14:M8-4-4 A function identifier shall either be used to call the function or it shall be preceded by &.
MisraC++2008 MisraC++2008:8-4-4 A function identifier shall either be used to call the function or it shall be preceded by &.
CWE CWE:704 Incorrect Type Conversion or Cast
JSF++ JSF++:183 Every possible measure should be taken to avoid type casting.
Availability Available for C and C++.
Enabling Checks for this warning class are enabled by default. To disable them, add the following WARNING_FILTER rule to the project configuration file.
WARNING_FILTER += discard class="Varargs Function Cast"

Example

typedef void (*va_t)(int, ...);
void E( int i, int j ) {}

int main( void ) {
  va_t va = (va_t)E;  /* 'Varargs Function Cast' warning issued here */

   va(1,2,3);
   return 42;
}

Relevant Configuration File Parameters

The following configuration file parameters affect checks for this warning class.