CertC-DCL16¶
Use “L,” not “l,” to indicate a long value
Required inputs: IR
Lowercase letter l (ell) can easily be confused with the digit 1 (one). This can be particularly confusing when indicating that an integer literal constant is a long value. This recommendation is similar to DCL02-C. Use visually distinct identifiers . Likewise, you should use uppercase LL rather than lowercase ll when indicating that an integer literal constant is a long long value.
To be precise when using modifiers to indicate the type of an integer literal, the first character may not be l . It may be L , u , or U . Subsequent characters have no strict case requirements.
Noncompliant Code Example
This noncompliant example highlights the result of adding an integer and a long value even though it appears that two integers 1111 are being added:
printf("Sum is %ld\n", 1111 + 111l);
|
Compliant Solution
The compliant solution improvises by using an uppercase L instead of lowercase l to disambiguate the visual appearance:
printf("Sum is %ld\n", 1111 + 111L);
|
Risk Assessment
Confusing a lowercase letter l (ell) with a digit 1 (one) when indicating that an integer denotation is a long value could lead to an incorrect value being written into code.
| Recommendation | Severity | Likelihood | Detectable | Repairable | Priority | Level |
|---|---|---|---|---|---|---|
| DCL16-C | Low | Unlikely | Yes | Yes | P3 | L3 |
Related Guidelines
| SEI CERT C++ Coding Standard | DCL16-CPP. Use "L," not "l," to indicate a long value |
| MISRA C:2012 | Rule 7.3 (required) |
Bibliography
| [ Lockheed Martin 2005 ] | AV Rule 14, Literal suffixes shall use uppercase rather than lowercase letters |
Possible Messages
Key |
Text |
Severity |
Disabled |
|---|---|---|---|
lowercase_l_suffix |
Lowercase “l” should not be used {}in a literal suffix |
None |
False |
Options¶
This rule shares the following common options: confidence, exclude_in_macros, exclude_messages_in_system_headers, excludes, extend_exclude_to_macro_invocations, includes, justification_checker, languages, post_processing, provider, report_at, severity
The following places define options that affect this rule: Stylechecks, Analysis-GlobalOptions
check_only_first_character¶
check_only_first_character : bool = True
l.