Why approxEqual not working for integers in dmd 2068-b2
Daniel Kozák via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Jul 28 00:42:32 PDT 2015
On Tue, 28 Jul 2015 02:16:56 +0000
"lobo" <swamplobo at gmail.com> wrote:
> Hi all,
>
> I have a bunch of unittests for template code taking any numeric
> type. Because I'm lazy I just use the approxEqual for both
> floating point and integer comparisons in these tests.
>
> In DMD 2067.1 everthing compiled OK but in 2068-b2 I get the
> errors shown at the end of this post for integer types.
>
>
> I'd like to know if it is OK to use approxEqual like I am in
> unittests and why approxEqual was changed, if it was intentional,
> for learning more about good use of D language
>
>
> Thanks,
> lobo
>
>
>
> Test code:
> ---
> void main() {
>
> int a = 10;
> assert(approxEqual(10, a));
>
> }
> ---
> Errors:
>
> src/phobos/std/math.d(6718): Error: std.math.fabs called with
> argument types (int) matches both:
> src/phobos/std/math.d(3415): std.math.fabs(real x)
> and:
> /src/phobos/std/math.d(3421): std.math.fabs(float x)
> /src/phobos/std/math.d(6725): Error: std.math.fabs called with
> argument types (int) matches both:
> /src/phobos/std/math.d(3415): std.math.fabs(real x)
> and:
> /src/phobos/std/math.d(3421): std.math.fabs(float x)
> /src/phobos/std/math.d(6726): Error: std.math.fabs called with
> argument types (int) matches both:
> /src/phobos/std/math.d(3415): std.math.fabs(real x)
> and:
> /src/phobos/std/math.d(3421): std.math.fabs(float x)
> /src/phobos/std/math.d(6736): Error: template instance
> std.math.approxEqual!(int, int, double) error instantiating
> hack.d(13): instantiated from here: approxEqual!(int, int)
> Failed: ["dmd", "-v", "-o-", "hack.d", "-I."]
> ---
Even if this will be considered as non compiler bug, it is a regression
on phobos side and should be addressed. So please fill a bug report on
http://issues.dlang.org
More information about the Digitalmars-d-learn
mailing list