Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[stable] Fix Issue 19219 - Could not CTFE with std.math.exp #8660

Merged
merged 1 commit into from Sep 7, 2018

Conversation

kinke
Copy link
Contributor

@kinke kinke commented Sep 4, 2018

The underlying issue is an apparent CTFE bug wrt. passing static immutable static arrays by (const) ref, see https://issues.dlang.org/show_bug.cgi?id=17351#c10. That makes this poly() optimization not CTFE-able.

@dlang-bot
Copy link
Contributor

Thanks for your pull request and interest in making D better, @kinke! 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 annotated coverage diff directly on GitHub with CodeCov's browser extension
  • 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
19219 regression Could not CTFE with std.math.exp from 2.082.0

Testing this PR locally

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

dub fetch digger
dub run digger -- build "stable + dmd#8660"

@@ -124,6 +124,13 @@ extern (C++) Expression eval_log10(Loc loc, FuncDeclaration fd, Expressions* arg
return new RealExp(loc, CTFloat.log10(arg0.toReal()), arg0.type);
}

extern (C++) Expression eval_exp(Loc loc, FuncDeclaration fd, Expressions* arguments)
Copy link
Contributor

Choose a reason for hiding this comment

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

Not my expertise but Walter has changed a lot of passing Loc by value to pass by const ref

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, but the other builtins have the same signature, and add_builtin requires it.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ah, ok.

@Geod24 Geod24 closed this Sep 6, 2018
@Geod24 Geod24 reopened this Sep 6, 2018
@thewilsonator
Copy link
Contributor

Win32: rm: cannot remove ‘test_results/runnable/test2.exe’: Device or resource busy looks like it needs another resuscitation.

@dlang-bot dlang-bot merged commit 09c657a into dlang:stable Sep 7, 2018
@kinke kinke deleted the exp_ctfe branch September 7, 2018 10:42
@@ -381,6 +388,7 @@ public extern (C++) void builtin_init()
add_builtin("_D3std4math3tanFNaNbNiNeeZe", &eval_tan);
add_builtin("_D3std4math4sqrtFNaNbNiNeeZe", &eval_sqrt);
add_builtin("_D3std4math4fabsFNaNbNiNeeZe", &eval_fabs);
add_builtin("_D3std4math3expFNaNbNiNeeZe", &eval_exp);
Copy link
Member

Choose a reason for hiding this comment

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

Could that builtin have gone to druntime instead ? AFAIK that's what we are trying to do nowadays (well, since a few years), and this list should probably be purged since many of those builtin just forward to druntime AFAIK.

Copy link
Contributor Author

@kinke kinke Sep 10, 2018

Choose a reason for hiding this comment

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

I think you mixed something up here. These CTFE builtins are generally used for non-CTFEable functions, e.g., if implemented in asm. None of the math ones use druntime IIRC, but the host's C functions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants