D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 18349 - std/math.d(543,33): Deprecation: integral promotion not done for -x
Summary: std/math.d(543,33): Deprecation: integral promotion not done for -x
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 normal
Assignee: No Owner
URL:
Keywords: pull
Depends on:
Blocks:
 
Reported: 2018-02-01 08:46 UTC by Timothee Cour
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Timothee Cour 2018-02-01 08:46:40 UTC
/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 Timothee Cour 2018-02-07 00:26:54 UTC
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;
    }
}
Comment 2 basile-z 2018-02-07 08:55:28 UTC
Yeah nobody seen that "Unqual" is needed during the review.

https://github.com/dlang/phobos/pull/5958/files

I'm gonna handle this since i feel 50% responsible
Comment 3 basile-z 2018-02-07 09:04:40 UTC
The constraint is already commented...

https://github.com/dlang/phobos/pull/6014
https://github.com/dlang/phobos/pull/6014/files#diff-8b9f1870415268a4c40b628d596dc405R549

Maybe the fix can be done anyway
Comment 4 basile-z 2018-02-07 09:12:02 UTC
pull: https://github.com/dlang/phobos/pull/6135
Comment 5 github-bugzilla 2018-02-07 20:06:38 UTC
Commits pushed to master at https://github.com/dlang/phobos

https://github.com/dlang/phobos/commit/a2ab91ad483a18c277490fe2a6d725054ad39584
fix issue 18349 - std/math.d(543,33): Deprecation: integral promotion not done for -x

https://github.com/dlang/phobos/commit/9087e479618a2ad75960569cabfa75ce09255fd7
Merge pull request #6135 from BBasile/issue-18349

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>