www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 21997] New: CTFE should allow function pointer casts with

https://issues.dlang.org/show_bug.cgi?id=21997

          Issue ID: 21997
           Summary: CTFE should allow function pointer casts with
                    different attributes
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: moonlightsentinel disroot.org

The following works at runtime but is rejected during CTFE:

int nonPureFunc(int i)
{
    return 2 * i;
}

void main()
{
    auto pureFunc = cast(int function(int) pure) &nonPureFunc;
    assert(pureFunc(2) == 4);
}

--
Jun 06