Bug 6092 – Can't cast primitive to same-sized static array

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
Other
OS
All
Creation time
2011-06-02T13:38:32Z
Last change time
2024-12-13T17:55:25Z
Assigned to
No Owner
Creator
Nick Sabalausky
Moved to GitHub: dmd#18345 →

Comments

Comment #0 by bus_dbugzilla — 2011-06-02T13:38:32Z
This works, and is a very useful trick: struct Foo {uint f;} void main(){ Foo a; ubyte[] b = cast(ubyte[4])a; } However, the following generates an error: void main(){ uint a; ubyte[] b = cast(ubyte[4])a; } The error: Error: e2ir: cannot cast a of type uint to type ubyte[4u]
Comment #1 by verylonglogin.reg — 2013-11-09T10:57:08Z
A report for e2ir ICE from original testcase: Issue 11484
Comment #2 by k.hara.pg — 2015-06-22T05:38:11Z
From the past, DMD glue layer does not support a cast from primitive type to static array. And from 2.065, it's changed to semantic error. Therefore, the rejection is intentional. Downgrade to enhancement issue.
Comment #3 by b2.temp — 2020-02-20T12:23:00Z
*** Issue 7328 has been marked as a duplicate of this issue. ***
Comment #4 by robert.schadek — 2024-12-13T17:55:25Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18345 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB