www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 15110] New: pragma(inline) rarely works how I want it to


          Issue ID: 15110
           Summary: pragma(inline) rarely works how I want it to
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Windows
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: turkeyman gmail.com

pragma(inline, true)
R normalisedSubtract(T, U, R = ResultType!(T, U))(T a, U b)
    R x = cast(R)a;//convertNormInt!R(a);
    R y = cast(R)b;//convertNormInt!R(b);
    static if(isUnsigned!R)
        if(x <= y)
            return 0;
        return cast(R)(x - y);
        auto r = x - y;
        if(r < R.min)
            r = R.min;
        else static if(isSigned!R)
            if(r > R.max)
                r = R.max;
        return cast(R)r;

src\std\experimental\color\internal\normint.d(90): Error: function
std.experimental.color.internal.normint.normalisedSubtract!(ubyte, ubyte,
ubyte).normalisedSubtract cannot inline function

This function is literally nothing more than a single integer subtract.
I have no idea why this won't inline. I experience this general problem quite a
Strangely, the addition compliment to this function doesn't complain.

Sep 24 2015