[Issue 21446] New: Cannot initialize a static array from a struct field of dynamic array type at compile time

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Dec 2 14:54:47 UTC 2020


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

          Issue ID: 21446
           Summary: Cannot initialize a static array from a struct field
                    of dynamic array type at compile time
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Keywords: CTFE, rejects-valid
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: maxsamukha at gmail.com

struct S {
    int[] a;
}

enum s = S(new int[1]);
int[1] a = s.a;

void main() {    
}

onlineapp.d(8): Error: cannot cast expression S([0]).a of type int[] to int[1]


Compiles if S is constructed directly in the initializer:

int[1] a = S(new int[1]).a; // ok

--


More information about the Digitalmars-d-bugs mailing list