Fix bug 9937 CTFE floats don't overflow correctly#3590
Closed
donc wants to merge 2 commits into
Closed
Conversation
Collaborator
Author
This test doesn't work if there is floating point round-off error.
This fixes the bug in comment 4 of bug 9937. Although CTFE floats may use higher precision than is available on the target machine, it is impossible for that extra precision to survive to runtime. This commit forces the extra bits to be discarded at the end of CTFE, rather than in the glue layer. This eliminates the bizarre anomalies in bug 9937 where a variable has two values at the same time (!) It also opens the way for CTFE to calculate with much higher precision than is available at runtime.
Member
|
This is failing to compile because |
Contributor
|
@WalterBright It was introduced in #1383 in |
Member
|
Seems to have been subsequently removed. |
Member
|
This should be put into Port or Target as it depends on compiler using native floats (GDC doesn't). |
Member
|
ping? |
Member
|
I'd be happy to rebase with my proposal (putting it in Target) - we can discuss at Dconf whether we actually want this. |
Member
|
Rebased and raised new PR here #5191 Closing this PR. |
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.
This fixes the bug in comment 4 of bug 9937.
https://issues.dlang.org/show_bug.cgi?id=9937#c4
Although CTFE floats may use higher precision than is available on the target machine, it is impossible for that extra precision to survive to runtime.
This commit forces the extra bits to be discarded at the end of CTFE, rather than in the glue layer. This eliminates the bizarre anomalies in bug 9937 where a variable has two values at the same time (!) It also opens the way for CTFE to calculate with much higher precision than is available at runtime.
This pull request does not affect floating point overflow inside CTFE, which is what Walter found controversial in that big report. It's only the transition from CTFE to runtime which is affected.