Bug 22922 – Support empty array literal in -betterC
Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2022-03-25T04:42:52Z
Last change time
2024-08-14T23:16:24Z
Keywords
pull
Assigned to
No Owner
Creator
andy-hanson
Comments
Comment #0 by andy-hanson — 2022-03-25T04:42:52Z
There is an unnecessary error for empty array literals when -betterC is enabled.
```
extern(C) void main() {
int[] x = [];
int[] y = (cast(int*) null)[0 .. 0];
}
```
Compile with `dmd a.d -betterC` and it outputs:
```
a.d(2): Error: `TypeInfo` cannot be used with -betterC
```
Since the expression `(cast(int*) null)[0 .. 0]` works, DMD should be able to translate `[]` into it without needing TypeInfo.
Comment #1 by dlang-bot — 2022-04-17T21:28:00Z
@dkorpel created dlang/dmd pull request #14004 "Fix issue 22922 - Support empty array literal in -betterC" fixing this issue:
- Fix issue 22922 - Support empty array literal in -betterC
https://github.com/dlang/dmd/pull/14004
Comment #2 by dlang-bot — 2022-04-18T10:05:36Z
dlang/dmd pull request #14004 "Fix issue 22922 - Support empty array literal in -betterC" was merged into master:
- eff4ab3fecdcc4596b0f300e519d27778d38434e by Dennis Korpel:
Fix issue 22922 - Support empty array literal in -betterC
https://github.com/dlang/dmd/pull/14004
Comment #3 by dkorpel — 2024-08-14T23:16:24Z
*** Issue 5788 has been marked as a duplicate of this issue. ***