www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - overload resolution on double-edged types

reply tetsuya <tetsuya_member pathlink.com> writes:
tested on windows XP, dmd 0.102

maybe not a new one, but could't find the post..


pow(real, real), pow(real, uint) and pow(real, int) are
overloaded in std.math, and the following code fails to
be compiled.


<code>
import std.math;

void main()
{
/*
* want to use pow(real, uint)
* because this one is the fastest
*/
pow(5.0, 6u);         // line9
}
</code>


the compiler message:
bug.d(9): function pow overloads real(real x,uint n) and
real(real x,real y) both match argument list for pow


dmd also fails to compile the following alternatives.

pow(5.0, 6);
pow(5.0, cast(uint) 6);
pow(5.0, cast(uint)(6));
pow(5.0, e);          // uint e = 6; (declared ahead)


you can successfully compile pow(5.0, 6.0) because 6.0
can never be interpreted as uint or int.  but there seems
to be no way to inform dmd that a specified number is
no real, no int, but an uint.


tetsuya
Oct 16 2004
parent Thomas Kuehne <eisvogel users.sourceforge.net> writes:
added to dstress:
svn://svn.kuehne.cn/dstress/run/overload_08.d
.
svn://svn.kuehne.cn/dstress/run/overload_11.d

Thomas

In article <ckrq8e$1cnl$1 digitaldaemon.com>, tetsuya says...
pow(real, real), pow(real, uint) and pow(real, int) are
overloaded in std.math, and the following code fails to
be compiled.


<code>
import std.math;

void main()
{
/*
* want to use pow(real, uint)
* because this one is the fastest
*/
pow(5.0, 6u);         // line9
}
</code>


the compiler message:
bug.d(9): function pow overloads real(real x,uint n) and
real(real x,real y) both match argument list for pow


dmd also fails to compile the following alternatives.

pow(5.0, 6);
pow(5.0, cast(uint) 6);
pow(5.0, cast(uint)(6));
pow(5.0, e);          // uint e = 6; (declared ahead)


you can successfully compile pow(5.0, 6.0) because 6.0
can never be interpreted as uint or int.  but there seems
to be no way to inform dmd that a specified number is
no real, no int, but an uint.


tetsuya
Oct 28 2004