Skip to content
This repository has been archived by the owner on Oct 12, 2022. It is now read-only.

Fix Issue 20760 - checkaction=context doesnt print floating point num… #3058

Merged
merged 1 commit into from
Apr 23, 2020

Conversation

MoonlightSentinel
Copy link
Contributor

@MoonlightSentinel MoonlightSentinel commented Apr 22, 2020

…bers correctly

This fixes most issues allthough casting from real to c_long_double might be
problematic for platforms where D's real uses 80 bits but C's long double is
only 64 bit wide (e.g. Win64).

Note that this might cause some deprecations because of https://issues.dlang.org/show_bug.cgi?id=20759

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @MoonlightSentinel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please verify that your PR follows this checklist:

  • My PR is fully covered with tests (you can see the coverage diff by visiting the details link of the codecov check)
  • My PR is as minimal as possible (smaller, focused PRs are easier to review than big ones)
  • I have provided a detailed rationale explaining my changes
  • New or modified functions have Ddoc comments (with Params: and Returns:)

Please see CONTRIBUTING.md for more information.


If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment.

Bugzilla references

Auto-close Bugzilla Severity Description
20760 normal checkaction=context doesnt print floating point numbers correctly

Testing this PR locally

If you don't have a local development environment setup, you can use Digger to test this PR:

dub run digger -- build "master + druntime#3058"

@dlang-bot dlang-bot added the Bug Fix Include reference to corresponding bugzilla issue label Apr 22, 2020
else // ireal
{
static if (is(LD == real))
alias R = ireal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't R be a C type? I didn't think that C supported imaginary D types.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Casting to a non-imaginary type yields 0, e.g.

ireal num = 2i;
writeln(cast(double) num);    // 0
writeln(cast(idouble) num);   // 2i

But ireal is stored the same way as real IIRC.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see what the point of this is then. I was thinking the issue was that C wasn't properly using the types because of the imaginariness.

One last thing: put a static assert that V is ireal. It shouldn't affect compilation time at all, and ensures some weird problem doesn't creep in here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

else // ireal
{
static if (is(LD == real))
alias R = ireal;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I see what the point of this is then. I was thinking the issue was that C wasn't properly using the types because of the imaginariness.

One last thing: put a static assert that V is ireal. It shouldn't affect compilation time at all, and ensures some weird problem doesn't creep in here.

…bers correctly

This fixes most issues allthough casting from real to c_long_double might be
problematic for platforms where D's real uses 80 bits but C's long double is
only 64 bit wide (e.g. Win64).
@dlang-bot dlang-bot merged commit 9087710 into dlang:master Apr 23, 2020
@MoonlightSentinel MoonlightSentinel deleted the assert-floats branch April 23, 2020 13:02
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Bug Fix Include reference to corresponding bugzilla issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants