Given the following code: ```d auto str = "hello"; auto wstr = cast(wstring)str; ``` The array cast cannot complete, because it would require 2.5 wchars. Regardless of the correctness of this attempt, the message is confusing: ``` An array of size 5 does not align on an array of size 4, so `immutable(char)` cannot be cast to `immutable(wchar)` ``` 1. I never requested an array of size 4, so I'm not sure why that is in the message. 2. It's not a matter of alignment, but of size. 3. You can cast an immutable char to an immutable wchar, so the message is wrong 4. The bytes are displayed here, not the lengths, which isn't as useful, there is no need to have the user work out the math. I am writing a PR to fix this message, this is the bug report for that fix.
@schveiguy updated dlang/druntime pull request #3792 "Fix confusing message on array cast failure." fixing this issue: - Fix issue 22964 -- array cast failure message awkwardly worded https://github.com/dlang/druntime/pull/3792
dlang/druntime pull request #3792 "Fix confusing message on array cast failure." was merged into master: - a91547cbb359e3a9b46e52513b457fc05f67298d by Steven Schveighoffer: Fix issue 22964 -- array cast failure message awkwardly worded https://github.com/dlang/druntime/pull/3792