https://issues.dlang.org/show_bug.cgi?id=23063
Issue ID: 23063
Summary: It is possible to return a noreturn value
Product: D
Version: D2
Hardware: x86_64
OS: All
Status: NEW
Severity: blocker
Priority: P1
Component: dmd
Assignee: [email protected]
Reporter: [email protected]
noreturn func()
{
noreturn a;
return a;
}
void main()
{
func();
}
This code compiles and runs succefully, despite the dip [1] explicitly stating:
"Defining a noreturn variable with no initialization expression generates an
assert(0) only if the variable is accessed, which can be useful in generic code
where unused noreturn variables may be declared. Generating the assert(0) as
soon as the variable is live in these cases could prematurely end the program."
This currently blocks: https://github.com/dlang/dmd/pull/12898
[1] https://github.com/dlang/DIPs/blob/master/DIPs/accepted/DIP1034.md
--