Bug 12560 – [CTFE] Accepts invalid array assign of void[], breaks type system

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Windows
Creation time
2014-04-11T19:27:48Z
Last change time
2024-12-13T18:19:46Z
Keywords
accepts-invalid, CTFE
Assigned to
No Owner
Creator
Dmitry Olshansky
See also
https://issues.dlang.org/show_bug.cgi?id=17148, https://issues.dlang.org/show_bug.cgi?id=15704
Moved to GitHub: dmd#17652 →

Comments

Comment #0 by dmitry.olsh — 2014-04-11T19:27:48Z
Tested with DMD 2.066, commit 497b168d1acf28a809f71efa4d7cac908a6d8b7f // struct A{ short a; } struct B{ ubyte b; } enum call = (){ A[] a = [ A(1), A(2)]; B[] b = [ B(3), B(4)]; void[] pa = a[]; void[] pb = b[]; pa[] = pb[]; // length mismatch is silently ignored at CTFE? pa[0..2] = pb[]; // static assert(is(typeof(a[0]) == A)); /passes return a[0]; }; enum x = call(); pragma(msg, typeof(x)); //prints A pragma(msg, x); //prints B(cast(ubyte)3) void main() { auto y = call(); assert(y == x); }
Comment #1 by n8sh.secondary — 2021-03-18T07:19:57Z
As of 2.072 this code does not compile in `@safe`: "Error: cannot copy void[] to void[] in @safe code." The interesting CTFE behavior still occurs as of 2.096.
Comment #2 by robert.schadek — 2024-12-13T18:19:46Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17652 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB