[Issue 17341] New: Partial initialization of static array should not be allowed

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sat Apr 22 10:22:03 PDT 2017


https://issues.dlang.org/show_bug.cgi?id=17341

          Issue ID: 17341
           Summary: Partial initialization of static array should not be
                    allowed
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: b2.temp at gmx.com

In this example:

```
enum E{e0,e1,e2}
static immutable int[E.max + 1]  a = [0,1]; // oops no 3rd element
static assert(isStaticArray!(typeof(a))); // no detected
```

we use an enum to define the size of a static array. The ArrayInitializer only
sets the 2 first elements and nothing allows to statically check the omission
(that could happen for example when adding new members to an enum).

Two possible actions:
- The compiler could emit a warning for this case.
- Deprecate "partial initialization of static arrays" and update the
specifications.

--


More information about the Digitalmars-d-bugs mailing list