Bug 24701 – No error produced from casted noreturn variable

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2024-08-14T02:06:15Z
Last change time
2024-08-21T08:10:23Z
Keywords
pull
Assigned to
No Owner
Creator
elpenguino+D

Comments

Comment #0 by elpenguino+D — 2024-08-14T02:06:15Z
``` 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.
Comment #1 by dlang-bot — 2024-08-19T12:42:10Z
@RazvanN7 created dlang/dmd pull request #16796 "Fix Bugzilla 24701 - No error produced from casted noreturn variable" fixing this issue: - Fix Bugzilla 24701 - No error produced from casted noreturn variable https://github.com/dlang/dmd/pull/16796
Comment #2 by dlang-bot — 2024-08-21T08:10:23Z
dlang/dmd pull request #16796 "Fix Bugzilla 24701 - No error produced from casted noreturn variable" was merged into master: - f99288f35c11fef32b37485fced182a6491d6389 by RazvanN7: Fix Bugzilla 24701 - No error produced from casted noreturn variable https://github.com/dlang/dmd/pull/16796