August 14 [Issue 24701] New: No error produced from casted noreturn variable | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24701 Issue ID: 24701 Summary: No error produced from casted noreturn variable Product: D Version: D2 Hardware: All OS: All Status: NEW Severity: normal Priority: P1 Component: dmd Assignee: nobody@puremagic.com Reporter: elpenguino+D@gmail.com ``` void main() { noreturn foo; try { //auto a = cast(int)noreturn.init; // error properly produced auto a = cast(int)foo; assert(0); } catch (Throwable e) { assert(e.msg == "Accessed expression of type `noreturn`"); } } ``` In this example, cast(int)foo results in an int(0). An error is expected, as in cast(int)noreturn.init. -- |
Copyright © 1999-2021 by the D Language Foundation