Bug 21953 – Arrayop accepted on static array, leading to runtime failure or wrong code
Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-05-23T03:15:01Z
Last change time
2022-02-07T19:26:08Z
Keywords
accepts-invalid, wrong-code
Assigned to
No Owner
Creator
Basile-z
Comments
Comment #0 by b2.temp — 2021-05-23T03:15:01Z
this code is accepted but should not
---
alias noreturn = typeof(*null);
void main()
{
noreturn[100] a;
a[] = null; // rt failure
// a[55] = null; // Error: cannot implicitly convert expression `null` of type `typeof(null)` to `noreturn`
}
---
as the commented expstmt does not pass.
Comment #1 by moonlightsentinel — 2021-11-20T21:39:24Z
The code is accepted and crashes even when replacing noreturn with int - not specific to noreturn.
The commented statement is rightfully rejected.
Comment #2 by contact — 2021-11-22T15:31:28Z
This also happens on direct assignment, if this helps on some implementation details:
```
int[100] a = null;
```
Comment #3 by b2.temp — 2022-02-07T19:24:40Z
indeed, null is converted to an empty array and causes a bounds error.