JavaScript is not currently enabled, but is required for full CodeSonar manual search and browse functionality.
If you are viewing this file in your hub's Web GUI, enable JavaScript in your browser: you will also need it for GUI functionality.
If you opened this file directly from disk, your browser may be directly suppressing JavaScript functionality: certain browsers perform this suppression on local files (but not files delivered by web servers) for security reasons.
| CodeSonar® 9.2p0 | CONFIDENTIAL | CodeSecure Inc |
The value of an expression is explicitly cast to an inappropriate essential type, as shown in the following table.
| Essential Type of Expression | Inappropriate Essential Type Categories for Cast |
|---|---|
| essentially Boolean | essentially character, essentially enum, essentially signed, essentially unsigned, essentially real floating, essentially complex floating |
| essentially character | essentially Boolean, essentially enum, essentially real floating, essentially complex floating |
| essentially enum | essentially Boolean, essentially enum (except casts to exactly the same enum, which would be redundant) |
| essentially signed | essentially
Boolean, essentially enum Exception: an integer constant expression with value 0 or 1 can be cast to an essentially Boolean type. |
| essentially unsigned | essentially
Boolean, essentially enum Exception: an integer constant expression with value 0 or 1 can be cast to an essentially Boolean type. |
| essentially real floating | essentially Boolean, essentially character, essentially enum |
| essentially complex floating | essentially Boolean, essentially character, essentially enum |
This warning class is based on the notion of essential type category as described in MISRA C:2012 Guidelines for the use of the C language in critical systems.
| Class Name | Inappropriate Cast Type | |||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | style | |||||||||||||||
| Mnemonic | LANG.TYPE.ICT | |||||||||||||||
| Categories |
|
|||||||||||||||
| Availability | Available for C and C++. |
|||||||||||||||
| Enabling | Checks for this warning class are disabled by default,
and require the unnormalized
C ASTs for the project. To enable them, add the following
WARNING_FILTER rule and RETAIN_UNNORMALIZED_C_AST specification to the project configuration file.
RETAIN_UNNORMALIZED_C_AST = Yes WARNING_FILTER += allow class="Inappropriate Cast Type" |
typedef enum {GO, PROCEED_WITH_CAUTION, STOP} action;
typedef enum {GREEN, ORANGE, RED} light;
char LANG_TYPE_ICT(action a, char ch){
light lt;
float f;
if (ch)
lt = a; /* not an explicit cast ('Mixed enum Type' warning issued) */
else
lt = (light) a; /* 'Inappropriate Cast Type' warning issued here */
if (lt > 1)
f = (float) ch; /* 'Inappropriate Cast Type' warning issued here */
else
f = (float) (lt==0); /* 'Inappropriate Cast Type' warning issued here */
if (f > 5)
return (char) a; /* permissible cast for this warning class */
else
return 'X';
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.