[previous] 2116 [next] Default argument promotion : plain char promoted to signed int.
Arithmetic type - Integral promotion REFERENCE - ISO:C90-6.3.2.2 Function Calls, 6.5.4.3 Function Declarators, 7.8.1 Variable argument list access macros

An expression of type char is being used as an argument in a function call and is being converted to type signed int according to the rules of default argument promotion.

This message will be generated if the function has not been declared or has been declared with an old style declaration. It will not be generated when default argument promotion results from a call to a function declared with a variable argument list.

If char is implemented as an unsigned type of the same size as int, the conversion will be to type unsigned int rather than signed int and message 2117 will be generated rather than message 2116.

For example:


/*PRQA S 1302,1303,3200,3209,3227,3408,3447,3602,3625 ++*/

extern void f1(int n, char p);                  /*              - new style function declaration   */
extern void f3();                               /* Message 3001 - old style function declaration   */
extern void f4(int n, ...);                     /*              - new style with variable arg list */

extern void foo(char pc)
{
    f1(1, pc);                                  /*                                      */
    f2(1, pc);                                  /* Message 2116 + 3335 - no declaration */
    f3(1, pc);                                  /* Message 2116                         */
    f4(1, pc);                                  /*                                      */
}

See also:

QA·C Source Code Analyser 8.1.2
© 2013 Programming Research.
www.programmingresearch.com
Personality Groups | Glossary | Message Index Contents