digitalmars.D.bugs - [Issue 16357] New: cast(T[])[x] casts x to T instead of [x] to T[]
- via Digitalmars-d-bugs (27/27) Aug 06 2016 https://issues.dlang.org/show_bug.cgi?id=16357
https://issues.dlang.org/show_bug.cgi?id=16357 Issue ID: 16357 Summary: cast(T[])[x] casts x to T instead of [x] to T[] Product: D Version: D2 Hardware: All OS: All Status: NEW Keywords: wrong-code Severity: normal Priority: P3 Component: dmd Assignee: nobody puremagic.com Reporter: thecybershadow gmail.com ////////////// test.d ////////////// void main() { uint x; ubyte[] data = cast(ubyte[])[x]; assert(data.length == 4); } //////////////////////////////////// This is surprising, because if the expression is split up into: auto arr = [x]; ubyte[] data = cast(ubyte[])arr; then the result is as expected (an array with 4 elements). --
Aug 06 2016