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 |
A cast or coercion from pointer type fl* to pointer type T*, or from T* to fl*, where:
| Class Name | Float Pointer Conversion | ||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Significance | style | ||||||||||||||||||||||||
| Mnemonic | LANG.CAST.PC.FLOAT | ||||||||||||||||||||||||
| 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="Float Pointer Conversion" |
double * to_floatptr(float *fptr, void* vptr, int *intptr, long int i ){
float *localfptr;
double d = (double) i; /* no pointer conversion */
localfptr = (float *) &d; /* 'Float Pointer Conversion' warning issued here (cast from double* to float*) */
switch (i) {
case 1:
fptr = intptr; /* 'Float Pointer Conversion' warning issued here (coercion from int* to float*)
* ('Incompatible Assignment Operands' warning also issued)
*/
break;
case 2:
fptr = (float*) intptr; /* 'Float Pointer Conversion' warning issued here (cast from int* to float*) */
break;
case 3:
fptr = i; /* ok: coercion from non-pointer to float*
* ('Incompatible Assignment Operands' warning issued)
*/
break;
case 4:
*fptr = *localfptr; /* no pointer conversion */
break;
default:
fptr = vptr; /* ok: coercion from void* to float* */
break;
}
return fptr; /* 'Float Pointer Conversion' warning issued here (coercion from float* to double*)
* ('Bad Return Value Type' warning also issued)
*/
}
int from_floatptr(float *fptr, double d, int i){
int localint = (int)fptr; /* ok: cast from float* to non-pointer */
int *iptr;
void *vptr = fptr; /* ok: coercion from float* to void* */
switch (i){
case 1:
iptr = fptr; /* 'Float Pointer Conversion' warning issued here (coercion from float* to int*)
* ('Incompatible Assignment Operands' warning also issued)
*/
break;
case 2:
iptr = (int *)&d; /* 'Float Pointer Conversion' warning issued here (cast from double* to int*) */
break;
default:
iptr = vptr; /* no float pointer involved */
break;
}
return *iptr + localint; /* no float pointer involved */
}
The following configuration file parameters affect checks for this warning class.
To report problems with this documentation, please visit https://support.codesecure.com/.