[previous] 1864 [next] The 2nd and 3rd operands of this conditional operator are of different 'essential signedness'. The result will be in the promoted type 'signed int'.
Arithmetic type - Balancing

The 2nd and 3rd operands of this conditional operator are of different essential type categories; one is 'essentially signed' and the other is 'essentially unsigned'. Both essential types are of lower rank than type int but the result of the operation will be of type int because of integral promotion.

For example:


/*PRQA S 1-9999 ++*/
/*PRQA S 1864 --*/

int f1864 (signed char a, unsigned char b)
{
  return (a > 0) ? a : b;           /* 1864 */
}


MISRA C:2012 Rules applicable to message 1864:

Rule-10.4  (Required) Both operands of an operator in which the usual arithmetic conversions are performed shall have the same essential type category


QA·C Source Code Analyser 8.1
MISRA C:2012 Compliance Module 1.0
© 2012 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index | MISRA C:2012 Rule Index Contents