rspec/rules/S818/cfamily/rule.adoc
Marco Borgeaud 76791bbfe8
Remove link to CERT Java from CFamily (#3296)
Remove irrelevant links from C/C++ descriptions. No effort was made to
replace them when there wasn't already a link to CERT C. This will be
done as part of a separate effort, one day.
2023-10-18 10:49:02 +00:00

52 lines
1.1 KiB
Plaintext

== Why is this an issue?
include::../description.adoc[]
=== Noncompliant code example
[source,cpp]
----
const int a = 0u; // Noncompliant
const int b = 0l; // Noncompliant
const int c = 0Ul; // Noncompliant
const int d = 0x12bu; // Noncompliant
const float m = 1.2f; // Noncompliant
const float n = 1.2l; // Noncompliant
----
=== Compliant solution
[source,cpp]
----
const int a = 0U;
const int b = 0L;
const int c = 0UL;
const int d = 0x12bU;
const float m = 1.2F;
const float n = 1.2L;
----
== Resources
* MISRA {cpp}:2008, 2-13-4 - Literal suffixes shall be upper case
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix
* https://wiki.sei.cmu.edu/confluence/x/cdYxBQ[CERT DCL16-C.] - Use "L," not "l," to indicate a long value
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
include::../message.adoc[]
'''
== Comments And Links
(visible only on this page)
include::../comments-and-links.adoc[]
endif::env-github,rspecator-view[]