Thread overview
[Issue 18630] std.math must CTFE
Nov 29, 2018
Eduard Staniloiu
Nov 29, 2018
Eduard Staniloiu
Nov 30, 2018
Simen Kjaeraas
Jun 10, 2019
Nicholas Wilson
Aug 23, 2019
Nathan S.
Sep 04, 2019
Nathan S.
Sep 04, 2019
Nathan S.
November 29, 2018
https://issues.dlang.org/show_bug.cgi?id=18630

Eduard Staniloiu <edi33416@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |edi33416@gmail.com

--- Comment #1 from Eduard Staniloiu <edi33416@gmail.com> ---
I think they already are, but I could be wrong.

Did you try forcing the compile time evaluation?
I had no problem running the following

```
enum r = pow(2.0, 5);
static assert(r == 32.0);

static assert(log(E) == 1);

enum f = sin(-2.0f);
static assert(fabs(f -  -0.909297f) < .00001);
```

Those are all altered unittests from std.math, to which I added `enum varName` and `static assert` instead of `assert`

--
November 29, 2018
https://issues.dlang.org/show_bug.cgi?id=18630

--- Comment #2 from Eduard Staniloiu <edi33416@gmail.com> ---
(In reply to Manu from comment #0)
> I usually workaround with a static constructor that pre-computes tables at startup, but that only solves some subset of cases. When I want those tables to interact with other CTFE code, I'm blocked.

Maybe you can replace the static ctor with this idiom https://p0nce.github.io/d-idioms/#Precomputed-tables-at-compile-time-through-CTFE

--
November 30, 2018
https://issues.dlang.org/show_bug.cgi?id=18630

Simen Kjaeraas <simen.kjaras@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |simen.kjaras@gmail.com

--- Comment #3 from Simen Kjaeraas <simen.kjaras@gmail.com> ---
(In reply to Eduard Staniloiu from comment #2)
> Maybe you can replace the static ctor with this idiom https://p0nce.github.io/d-idioms/#Precomputed-tables-at-compile-time-through- CTFE

That's exactly what he's trying to do. In 2.083.0, the following functions in std.math are still not CTFE-able:

nextPow2
truncPow2
asin
atan2
expi
lround
lrint
rndtol
quantize
frexp
ilogb
scalbn

Getting there, though - in 2.081.1, the list was about twice as big.

--
June 10, 2019
https://issues.dlang.org/show_bug.cgi?id=18630

Nicholas Wilson <iamthewilsonator@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |iamthewilsonator@hotmail.co
                   |                            |m

--- Comment #4 from Nicholas Wilson <iamthewilsonator@hotmail.com> ---
asin now works at compile time.

The rest still fail for the following reasons.

nextPow2  -- reinterpret
truncPow2 -- reinterpret
atan2     -- reinterpret
expi      -- asm
lround    -- no avail source
lrint     -- ditto
rndtol    -- ditto
uantize   -- ditto
frexp     -- reinterpret
ilogb     -- y.vu[3] is used before initialised
scalbn    -- asm

--
August 23, 2019
https://issues.dlang.org/show_bug.cgi?id=18630

Nathan S. <n8sh.secondary@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |n8sh.secondary@hotmail.com
         Resolution|---                         |DUPLICATE

--- Comment #5 from Nathan S. <n8sh.secondary@hotmail.com> ---
Marking this as a duplicate of #17007 since that one is older even though this is the issue with discussion.

*** This issue has been marked as a duplicate of issue 17007 ***

--
September 04, 2019
https://issues.dlang.org/show_bug.cgi?id=18630
Issue 18630 depends on issue 17705, which changed state.

Issue 17705 Summary: std.math.isFinite cannot run at compile-time https://issues.dlang.org/show_bug.cgi?id=17705

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|WORKSFORME                  |---

--
September 04, 2019
https://issues.dlang.org/show_bug.cgi?id=18630

Nathan S. <n8sh.secondary@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |17705


Referenced Issues:

https://issues.dlang.org/show_bug.cgi?id=17705
[Issue 17705] std.math.isFinite cannot run at compile-time
--
September 04, 2019
https://issues.dlang.org/show_bug.cgi?id=18630

Nathan S. <n8sh.secondary@hotmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|17705                       |


Referenced Issues:

https://issues.dlang.org/show_bug.cgi?id=17705
[Issue 17705] std.math.isFinite cannot run at compile-time
--