Fix missing _RP kind suffix on floating-point literals that are not binary-representable.#302
Open
chenyu76 wants to merge 1 commit into
Open
Fix missing _RP kind suffix on floating-point literals that are not binary-representable.#302chenyu76 wants to merge 1 commit into
_RP kind suffix on floating-point literals that are not binary-representable.#302chenyu76 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In Fortran, an unsuffixed literal like
0.1is of typedefault real(usually 32-bit single precision). WhenRPis configured as 64-bit double precision, comparing or combiningreal(RP)variables with unsuffixed literals triggers an implicit type conversion. Worse,0.1in single precision and0.1_RPin double precision are different binary approximations. This means a condition such asmay evaluate differently in rare cases.
This PR appends
_RPto unsuffixed floating-point literals that is not exactlyrepresentable in binary.
How They Were Detected
The missing suffixes were identified by fortran_float_number_extract, a simple tool that
fortran-src,After identification, I manually checked whether each literal needed to be rewritten.
Literals that were skipped
0.9in/fortran/tests/testsuite/bigprob.f90:23:43./fortran/original/.