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

          Issue ID: 21498
           Summary: Functions with delegate parameter overloaded on
                    attributes fail miserably
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: regression
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

The offending code is below (you should be able to comment-in @nogc using
-dip1000).

On my Windows machine, the listing compiles and runs seemingly without errors.
Note that all attributes including @safe are circumvented. For @nogc, use
-dip1000.

On run.dlang.org, running all DMD compilers, only 2.066 correctly points out
attribute violation. Since 2.067 the compiler is beigng "killed by signal 11"
(whatever that means). LDC segfaults.


int functional(int delegate(int) @system dg) @system
{
    int* p;
    int x;
    p = &x;
    if (auto result = dg(1)) return result;
    return 0;
}

int functional(int delegate(int) @safe pure nothrow @nogc dg) @safe pure
nothrow /*@nogc*/
{
    return functional(dg);
}

void main() @safe pure nothrow /*@nogc*/
{
    int x = 0;
    functional(i => x = i);
    assert(x == 1);
}

--

Reply via email to