[Issue 24701] New: No error produced from casted noreturn variable
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Aug 14 02:06:15 UTC 2024
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 at puremagic.com
Reporter: elpenguino+D at 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.
--
More information about the Digitalmars-d-bugs
mailing list