[Issue 23063] New: It is possible to return a noreturn value
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Apr 27 10:29:13 UTC 2022
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: nobody at puremagic.com
Reporter: razvan.nitu1305 at gmail.com
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
--
More information about the Digitalmars-d-bugs
mailing list