www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - math.pow fails at compile-time; is this a bug?

Content-Type: text/plain; charset=ISO-8859-1

template T(){
  enum a = pow(3.0, 2);
  enum b = pow(3, 2.0);

  alias T!() t;

compiling that I get:

/home/b/phobos/std/math.d(2369): Error: Cannot convert &real to ushort* at
compile time
/home/b/phobos/std/math.d(3292):        called from here: isNaN(y)
/home/b/phobos/std/math.d(3403):        called from here:
/home/b/phobos/std/math.d(3239):        called from here: pow(cast(real)x,y)
t.d(478):        called from here: pow(3,2)
t.d(485): Error: template instance units.T!() error instantiating

I guess this a bug?  any workarounds?

Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable

<br>template T(){<br>=A0 enum a =3D pow(3.0, 2);<br>=A0 enum b =3D pow(3, 2=
.0);<br>}<br><br>unittest<br>{<br>=A0 alias T!() t;<br>}<br><br>compiling t=
hat I get:<br><br>/home/b/phobos/std/math.d(2369): Error: Cannot convert &a=
mp;real to ushort* at compile time<br>
/home/b/phobos/std/math.d(3292):=A0=A0=A0=A0=A0=A0=A0 called from here: isN=
aN(y)<br>/home/b/phobos/std/math.d(3403):=A0=A0=A0=A0=A0=A0=A0 called from =
here: impl(x,cast(real)y)<br>/home/b/phobos/std/math.d(3239):=A0=A0=A0=A0=
=A0=A0=A0 called from here: pow(cast(real)x,y)<br>
t.d(478):=A0=A0=A0=A0=A0=A0=A0 called from here: pow(3,2)<br>t.d(485): Erro=
r: template instance units.T!() error instantiating<br><br>I guess this a b=
ug?=A0 any workarounds?<br><br>

Aug 19 2012