Skip to content

Commit

Permalink
Merge pull request #6135 from BBasile/issue-18349
Browse files Browse the repository at this point in the history
fix issue 18349 - std/math.d(543,33): Deprecation: integral promotion not done for -x
merged-on-behalf-of: Steven Schveighoffer <schveiguy@users.noreply.github.com>
  • Loading branch information
dlang-bot authored Feb 7, 2018
2 parents 378b710 + ec21afa commit 9087e47
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions std/math.d
Original file line number Diff line number Diff line change
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(Unqual!Num == short) || is(Unqual!Num == byte))))
{
static if (isFloatingPoint!(Num))
return fabs(x);
else
{
static if (is(Num == short) || is(Num == byte))
static if (is(Unqual!Num == short) || is(Unqual!Num == 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 9087e47

Please sign in to comment.