digitalmars.D.bugs - [Issue 13739] New: in CTFE making an array over an array copies the
- via Digitalmars-d-bugs (32/32) Nov 16 2014 https://issues.dlang.org/show_bug.cgi?id=13739
https://issues.dlang.org/show_bug.cgi?id=13739 Issue ID: 13739 Summary: in CTFE making an array over an array copies the data Product: D Version: D2 Hardware: x86_64 OS: Linux Status: NEW Keywords: CTFE, wrong-code Severity: normal Priority: P1 Component: DMD Assignee: nobody puremagic.com Reporter: ag0aep6g gmail.com bool test() { int[] a1 = [13]; int[][] a2 = [a1]; assert(a2[0] is a1); /* passes even in CTFE, weird */ assert(a2[0].ptr is a1.ptr); /* fails in CTFE */ a1[0] = 1; assert(a2[0][0] == 1); /* fails in CTFE */ a2[0][0] = 2; assert(a1[0] == 2); /* fails in CTFE */ return true; } void main() { version(rt) assert(test()); version(ct) static assert(test()); } --
Nov 16 2014