Skip to content

Fix bug 9937 CTFE floats don't overflow correctly#3590

Closed
donc wants to merge 2 commits into
dlang:masterfrom
don-clugston-sociomantic:ctfeFloatPrecision
Closed

Fix bug 9937 CTFE floats don't overflow correctly#3590
donc wants to merge 2 commits into
dlang:masterfrom
don-clugston-sociomantic:ctfeFloatPrecision

Conversation

@donc
Copy link
Copy Markdown
Collaborator

@donc donc commented May 26, 2014

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.

@donc
Copy link
Copy Markdown
Collaborator Author

donc commented May 28, 2014

This PR requires PR #3602 and PR #3594.

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.
@WalterBright
Copy link
Copy Markdown
Member

This is failing to compile because UnionFloatInt is undefined. I don't see it defined in the PR, where should it be?

@IgorStepanov
Copy link
Copy Markdown
Contributor

@WalterBright It was introduced in #1383 in ctfeexpr.c

@WalterBright
Copy link
Copy Markdown
Member

Seems to have been subsequently removed.

@ibuclaw
Copy link
Copy Markdown
Member

ibuclaw commented Nov 16, 2014

This should be put into Port or Target as it depends on compiler using native floats (GDC doesn't).

@andralex
Copy link
Copy Markdown
Member

ping?

@ibuclaw
Copy link
Copy Markdown
Member

ibuclaw commented Jan 30, 2015

I'd be happy to rebase with my proposal (putting it in Target) - we can discuss at Dconf whether we actually want this.

@ibuclaw
Copy link
Copy Markdown
Member

ibuclaw commented Oct 11, 2015

Rebased and raised new PR here #5191

Closing this PR.

@ibuclaw ibuclaw closed this Oct 11, 2015
@ibuclaw ibuclaw removed their assignment Dec 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants