Main Content

AUTOSAR C++14 Rule M2-13-4

Literal suffixes shall be upper case

Description

Rule Definition

Literal suffixes shall be upper case.

Rationale

Literal constants can end with the letter l (el). Enforcing literal suffixes to be upper case removes potential confusion between the letter l and the digit 1.

For consistency, use upper case constants for other suffixes such as U (unsigned) and F (float).

Troubleshooting

If you expect a rule violation but Polyspace® does not report it, see Diagnose Why Coding Standard Violations Do Not Appear as Expected.

Examples

expand all

const int a = 0l; //Noncompliant
const int b = 0L; //Compliant

In this example, both a and b are assigned the same literal constant. However, from a quick glance, one can mistakenly assume that a is assigned the value 01 (octal one).

Check Information

Group: Lexical Conventions
Category: Required, Automated

Version History

Introduced in R2019a