Annoying std.math issue

H. S. Teoh hsteoh at quickfur.ath.cx
Thu Mar 27 11:16:31 PDT 2014


Some time ago, Iain Buclaw kindly added non-asm implementations of math
functions in std.math. However, CTFE still seems unable to correctly
evaluate certain functions like atan2:

	import std.math;
	enum x = atan2(1.0, 2.0);

Compiler output:

	/usr/src/d/phobos/std/math.d(856): Error: asm statements cannot be interpreted at compile time
	/usr/src/d/phobos/std/math.d(917):        called from here: atan2(cast(real)y, cast(real)x)
	test.d(2):        called from here: atan2(1.00000, 2.00000)

Looking at std/math.d, it appears that version=InlineAsm_X86_Any is
defined, which leads to the asm implementation of atan2, which CTFE
can't interpret.

However, right below that block is an else block containing a D
implementation of atan2 that AFAICT *can* be interpreted in CTFE.

So it would appear that version=InlineAsm_X86_Any should be suppressed
during CTFE? But I'm not sure how this could be done in the compiler.

In any case, it's an annoying limitation. :-(


T

-- 
Never step over a puddle, always step around it. Chances are that whatever made it is still dripping.


More information about the Digitalmars-d mailing list