CC. Undefined Behavior
According to the [ Fortran 2018 ] and [ Fortran 2023 ] language standards, the behavior of a program is undefined when it violates a normative requirement of the language or executes a construct for which the standard specifies that a value, association status, pointer, object, or effect is undefined. Unlike the C Standard, the Fortran standard does not provide a dedicated annex enumerating undefined behaviors. Instead, such cases are specified throughout the document by means of normative requirements (typically expressed using shall) and statements indicating that a value, variable, pointer, association status, allocation status, or other entity is undefined; that the effect is undefined; or that a program is not standard-conforming.
The "Guideline" column in the following table identifies the coding practices that address each instance of undefined behavior (UB). The "Description" column provides a short description of the undefined behavior, optionally indicating a quoted or closely paraphrased from the Fortran 2018 and Fortran 2023 standards.
| UB | Description | Guideline |
|---|---|---|
| 1-F | Avoid undefined behavior due to uninitialized variables. | DCL03-F |
| 2-F | Conditionally initialized variables can lead to undefined behavior. | DCL04-F |
| 3-F | Uninitialized output arguments can lead to undefined behavior. | DCL05-F |
| 4-F | Explicitly declare the 'save' attribute or split the variable initialization to prevent unintended behavior. | DCL02-F |