== Why is this an issue?

include::../description.adoc[]

=== Noncompliant code example

[source,cpp]
----
void nonCompliant ( ) {
  float twoThirds = 2 / 3;
  long millisInYear = 1000 * 3600 * 24 * 365;
}
----

=== Compliant solution

[source,cpp]
----
void compliant1() {
  float twoThirds = 2.F / 3;
  long millisInYear = 1000L * 3600 * 24 * 365;
}
----
or

[source,cpp]
----
void compliant2() {
  float twoThirds = ((float) 2) / 3;
  long millisInYear = ((long) 1000) * 3600 * 24 * 365;
}
----

== Resources

=== Standards

* MISRA {cpp}:2008, 5-0-8 - An explicit integral or floating-point conversion shall not increase the size of the underlying type of a cvalue expression.
* CWE - https://cwe.mitre.org/data/definitions/190[CWE-190 - Integer Overflow or Wraparound]
* https://wiki.sei.cmu.edu/confluence/x/I9cxBQ[CERT, INT18-C.] - Evaluate integer expressions in a larger size before comparing or assigning to that size
* STIG Viewer - https://stigviewer.com/stig/application_security_and_development/2023-06-08/finding/V-222612[Application Security and Development: V-222612] - The application must not be vulnerable to overflow attacks.


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[]
