Bug 18349 – std/math.d(543,33): Deprecation: integral promotion not done for -x
Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-02-01T08:46:40Z
Last change time
2020-03-21T03:56:40Z
Keywords
pull
Assigned to
No Owner
Creator
Timothee Cour
Comments
Comment #0 by timothee.cour2 — 2018-02-01T08:46:40Z
/Users/timothee/homebrew/opt/dmd/include/dlang/dmd/std/math.d(543,33): Deprecation: integral promotion not done for -x, use '-transition=intpromote' switch or -cast(int)(x)
dub run dfmt -- -h
Building package dfmt in /Users/timothee/.dub/packages/dfmt-0.5.0/dfmt/
Fetching libdparse 0.7.1 (getting selected version)...
Performing "debug" build using dmd for x86_64.
libdparse 0.7.1: building configuration "library"...
dfmt 0.5.0: building configuration "application"...
/Users/timothee/homebrew/opt/dmd/include/dlang/dmd/std/math.d(543,33): Deprecation: integral promotion not done for -x, use '-transition=intpromote' switch or -cast(int)(x)
/Users/timothee/homebrew/opt/dmd/bin/dmd --version
DMD64 D Compiler v2.078.1
Comment #1 by timothee.cour2 — 2018-02-07T00:26:54Z
IIRC: was triggered from dfmt by an input of type `immutable(short)` looks like logic breaks when input is immutable?
Num abs(Num)(Num x) @safe pure nothrow
if ((is(typeof(Num.init >= 0)) && is(typeof(-Num.init)) ||
(is(Num == short) || is(Num == byte))) &&
!(is(Num* : const(ifloat*)) || is(Num* : const(idouble*))
|| is(Num* : const(ireal*))))
{
static if (isFloatingPoint!(Num))
return fabs(x);
else
{
static if (is(Num == short) || is(Num == byte))
return x >= 0 ? x : cast(Num) -int(x);
else
return x >= 0 ? x : -x;
}
}