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.0p0 Hot Tips | CONFIDENTIAL | CodeSecure Inc |
The default association for a C generic selection expression is selected, but a human reader might expect a different outcome if they (mistakenly) believe that implicit pointer conversion will take place.
The controlling expression of a C generic selection undergoes lvalue conversion, but does not undergo implicit pointer conversion. Once lvalue conversion has taken place, the controlling expression type must exactly match an association type in the association list in order for that association to be selected: otherwise, the default association is selected.
| Class Name | Implicit Pointer Type Conversion in Selection of C Generic | ||||||
|---|---|---|---|---|---|---|---|
| Significance | style | ||||||
| Mnemonic | LANG.TYPE.CGEN.IMPTC | ||||||
| Categories |
|
||||||
| Availability | Available for C only (not 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="Implicit Pointer Type Conversion in Selection of C Generic" |
#define QUALINT_PTRS(y) (_Generic(y, \
const int*: 0, \
volatile int*: 1, \
default: -1))
#define INT_PTR(y) (_Generic(y, \
int*: 0, \
default: -1))
int lang_type_cgen_imptc(int *pi, void *pv, float *pf){
int rv = 0;
rv += QUALINT_PTRS(pi); /* 'Implicit Pointer Type Conversion in Selection of C Generic' warning issued here
* - selection type int* does not match any non-default association type {const int*, volatile int*},
* but author/reader might have expected otherwise.
*/
rv += INT_PTR(pi); /* ok: selection type int* matches int* association type */
rv += INT_PTR(pv); /* 'Implicit Pointer Type Conversion in Selection of C Generic' warning issued here
* - selection type int* does not match any non-default association type {void*},
* but author/reader might have expected otherwise.
*/
rv += INT_PTR(pf); /* ok: selection type int* does not match non-default association type float*, but
* this is not likely to reflect (or cause) confusion about implicit conversion.
*/
return rv;
}
The following configuration file parameters affect checks for this warning class.