[previous] 1272 [next] Redundant leading zeroes on a numeric constant.
Constants

This octal or hex constant has leading zeroes which seem to be unnecessary. Message 1272 is intended to identify situations where there may be a typing error or confusion over the intended type of the constant.

Octal constants

The message is generated when the constant has more than one leading zero.

Hexadecimal constants

The message is generated when the constant has more leading zeroes than the type of the constant would suggest. For example, if the constant is of type int and an int is implemented in 16 bits, message 1272 will be generated if the constant contains more than 4 hexadecimal digits.

For example:


/*PRQA S 339,1277,2017,3120,3198,3408,3447,3625 ++*/
/****************************************
 * OPTIONS:
 *     1: -s int=16
 *     2: -s int=32
 ***************************************/
extern unsigned int a;

extern void foo(void)
{
                               /*************************/
                               /* -s int=16 * -s int=32 */
                               /*************************/
    /* OCTAL CONSTANTS */

    a = 015;                   /*           *           */
    a = 0015;                  /* 1272      * 1272      */
    a = 00015;                 /* 1272      * 1272      */

    /* HEX CONSTANTS */

    a = 0x0777;                /*           *           */
    a = 0x00777;               /* 1272      *           */
    a = 0x000777;              /* 1272      *           */
    a = 0x0000777;             /* 1272      *           */
    a = 0x00000777;            /* 1272      *           */
    a = 0x000000777;           /* 1272      * 1272      */
    a = 0x0000000777;          /* 1272      * 1272      */
}

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