[Issue 22922] New: Support empty array literal in -betterC
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Mar 25 04:42:52 UTC 2022
https://issues.dlang.org/show_bug.cgi?id=22922
Issue ID: 22922
Summary: Support empty array literal in -betterC
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: andy.pj.hanson at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list