Skip to content

Commit

Permalink
fix issue 18349 - std/math.d(543,33): Deprecation: integral promotion…
Browse files Browse the repository at this point in the history
… not done for -x
  • Loading branch information
Basile Burg committed Feb 7, 2018
1 parent 9b03a10 commit a2ab91a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions std/math.d
Expand Up @@ -553,13 +553,13 @@ auto abs(Num)(Num x)
// workaround for https://issues.dlang.org/show_bug.cgi?id=18251
//if (!isDeprecatedComplex!Num &&
//(is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) ||
//(is(Num == short) || is(Num == byte))))
//(is(Num : const(short)) || is(Num : const(byte)))))
{
static if (isFloatingPoint!(Num))
return fabs(x);
else
{
static if (is(Num == short) || is(Num == byte))
static if (is(Num : const(short)) || is(Num : const(byte)))
return x >= 0 ? x : cast(Num) -int(x);
else
return x >= 0 ? x : -x;
Expand Down Expand Up @@ -608,6 +608,8 @@ deprecated
byte b = -8;
assert(abs(s) == 8);
assert(abs(b) == 8);
immutable(byte) c = -8;
assert(abs(c) == 8);
}

@safe pure nothrow @nogc unittest
Expand Down

0 comments on commit a2ab91a

Please sign in to comment.