Compile-time evaluation of real expressions?
Alex Rønne Petersen
xtzgzorex at gmail.com
Fri Jan 6 15:03:39 PST 2012
On 06-01-2012 23:21, H. S. Teoh wrote:
> Hi All,
>
> As I understand it, compile-time execution *should* be able to evaluate
> floating-point functions, correct? Currently, I have this code:
>
> private static real cross_angles[6] = [
> real.nan,
> real.nan,
> real.nan,
> atan(sqrt(5)),
> PI_4,
> atan(sqrt(5)-2)
> ];
>
> But the compiler is complaining:
>
> /mnt/1/usr/include/d2/4.6/std/math.d:623: Error: asm statements cannot be interpreted at compile time
> /mnt/1/usr/include/d2/4.6/std/math.d:591: Error: cannot evaluate atan2(x,1.0e+0L) at compile time
>
> Is this an artifact of using gdc-4.6 instead of dmd? Or are certain
> floating-point functions not allowed in compile-time expressions?
>
> Thanks!
>
> P.S. I just starting learning and using D recently -- and totally loving
> it.
>
>
> T
>
Most likely those functions are just implemented using inline assembly,
therefore not usable in CTFE.
--
- Alex
More information about the Digitalmars-d-learn
mailing list