Bug 21955 – CastExp of noreturn is rejected by the backend
Status
RESOLVED
Resolution
WORKSFORME
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-23T03:33:01Z
Last change time
2021-09-28T16:02:46Z
Keywords
backend, ice
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2021-05-23T03:33:01Z
this code is rejected with an error in the backend, it should be a front-end error instead.
---
alias noreturn = typeof(*null);
int main()
{
noreturn a;
auto c = cast(int) a;
return 0;
}
---
> /tmp/temp_7F9C4DB5BA30.d:8:24: Error: e2ir: cannot cast `a` of type `noreturn` to type `int`
DMD git 9d718f2f8c7f34d3b616791493d9e71d7527f221
Comment #1 by moonlightsentinel — 2021-05-24T16:18:29Z
The cast is valid because the bottom type is implicitly convertible to any type. But the DIP requires the code to abort as soon as a is accessed, so the backend must emit the appropriate code instead of generating this error
Comment #2 by moonlightsentinel — 2021-06-21T20:38:24Z
*** Issue 22015 has been marked as a duplicate of this issue. ***