[Issue 12560] New: [CTFE] Accepts invalid array assign of void[], breaks type system
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Fri Apr 11 12:27:48 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=12560
Issue ID: 12560
Summary: [CTFE] Accepts invalid array assign of void[], breaks
type system
Product: D
Version: D2
Hardware: x86_64
OS: Windows
Status: NEW
Severity: normal
Priority: P1
Component: DMD
Assignee: nobody at puremagic.com
Reporter: dmitry.olsh at gmail.com
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);
}
--
More information about the Digitalmars-d-bugs
mailing list