I'm using QAC and I get the below message for the respective source code line. How can I cast it in order for QAC to "understand" it ?
Compiler used is gcc - it doesn't warn about this issue, as it is set to "iso c99".
#define DIAGMGR_SIGNED_2_BYTES_178 ((s16)178)
sK = (s16)(sE1 / DIAGMGR_SIGNED_2_BYTES_178);
^
Result of signed division or remainder operation may be implementation defined
.
A division ('/') or remainder ('%') operation is being performed in a signed integer type and the result may be implementation-defined. Message 3103 is generated for an integer division or remainder operation in a signed type where:
- One or both operands are non-constant and of signed integer type, or
- Both operands are integer constant expressions, one of negative value and one of positive value
A signed integer division or remainder operation in which one operand is positive and the other is negative may be performed in one of two ways:
- The division will round towards zero and any non-zero remainder will be a negative value
- The division will round away from zero and any non-zero remainder will be a positive value In the ISO:C99 standard the first approach is always used. In the ISO:C90 standard either approach may be used - the result is implementation defined. For example:
/PRQA S 3120,3198,3408,3447 ++/
extern int r; extern int si; extern void foo(void) { r = -7 / 4; /* Message 3103 *//* Result is -1 in C99 but may be -2 in C90 */ r = -7 % 4; /* Message 3103 *//* Result is -3 in C99 but may be 1 in C90 */ si = si / r; /* Message 3103 */ }