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

          Issue ID: 23364
           Summary: returning bottom type by ref should work
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: [email protected]
          Reporter: [email protected]

Compiled with a recent master DMD version, flags -preview=dip1000 and -run

-----------------------------
@safe ref foo(return ref noreturn arg){return arg;}
@safe void main()
{ foo(*null);
}
-----------------------------

The above example crashes at runtime with the following message:

-----------------------------
[email protected](1): Accessed expression of type `noreturn`
----------------
??:? _d_assert_msg [0x43a7c8]
??:? pure nothrow ref @nogc @safe noreturn app.foo(return ref noreturn)
[0x43a730]
??:? _Dmain [0x43a73e]
-----------------------------

The example should run without any error, because `foo` function does not
actually take or return the bottom value - only a (null) reference to one. It's
the same reason why this program runs without error:

-----------------------------
@safe ref foo(return ref int arg){return arg;}
@safe void main()
{ foo(*cast(int*)null);
}
-----------------------------

--

Reply via email to