Comment #0 by alphaglosined — 2022-12-04T08:42:46Z
As of dmd 2.101.0 power operator doesn't work in -betterC for double/double.
Due to using std.math : pow as the hook for this expression, which depends upon exp2 which isn't templated.
```
extern(C) void main() {
double input = 3f;
double power = 2;
double calculated = input ^^ power;
}
```
```
verify_pow_reg.obj : error LNK2019: unresolved external symbol __D3std4math11exponential4exp2FNaNbNiNeeZe referenced in function __D3std4math11exponential__T3powTdTdZQjFNaNbNiNeddZ4implFNaNbNiNfeeZe
```
Comment #1 by nick — 2022-12-04T17:57:59Z
Each exp2 overload forwards to template exp2Impl, and each are marked pragma(inline, true). So this should work if the inlining is done. (Though currently it makes no difference using -inline -O or not).
Comment #2 by alphaglosined — 2022-12-04T22:00:25Z
Unfortunately, run.dlang.io's run-all D compiler option appears to be broken, so I can't test if the recent changes to dmd's inliner caused this to break and hence be a regression.
But yeah I see three possibilities here:
1) Fix inlining
2) Template exp functions
3) Use libc pow instead
Of course, all these options are ignoring the forest. Why are there compiler hooks implemented in Phobos?
Comment #3 by ibuclaw — 2023-02-07T00:30:01Z
Any `T ^^ float` operation is by definition non-trivial, so I'm tempted to just close this as wontfix.
Comment #4 by robert.schadek — 2024-12-13T19:26:16Z