January 30 [Issue 24362] casting a string literal with a postfix to array re-interpret casts anything | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=24362 Walter Bright <bugzilla@digitalmars.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |bugzilla@digitalmars.com --- Comment #1 from Walter Bright <bugzilla@digitalmars.com> --- This should work: > auto v0 = cast(float[1]) "abcd"c; // re-interpret casts string bytes to float This should not compile: > auto v1 = cast(ubyte[300][2]) "abcd"c; // assert failure in dcast.d This should not compile: > auto v2 = cast(long[2]) "abcd"c; // assert failure in backend The rule for array casting is the size of the result should match the size of the operand. -- |
Copyright © 1999-2021 by the D Language Foundation