[dmd-internals] Casting string literal to static array
Daniel Murphy
yebblies at gmail.com
Fri Jan 24 21:10:13 PST 2014
In test23.d, there is this:
void test25()
{
char[6] cstr = "123456"c;
auto str1 = cast(wchar[3])(cstr);
writefln("str1: ", (cast(char[])str1).length , " : ", (cast(char[])str1));
assert(cast(char[])str1 == "123456"c);
auto str2 = cast(wchar[3])("789abc"c);
writefln("str2: ", (cast(char[])str2).length , " : ",
(cast(char[])str2));
assert(cast(char[])str2 == "789abc"c);
auto str3 = cast(wchar[3])("defghi");
writefln("str3: ", (cast(char[])str3).length , " : ",
(cast(char[])str3));
assert(cast(char[])str3 == "d\000e\000f\000"c);
}
I'm not sure we should allow the cast from "789abc"c to wchar[3].
I think if you want this behavior you should have to do
`cast(wchar[3])cast(char[6])"789abc"`.
Thoughts?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/dmd-internals/attachments/20140125/d1ea72ad/attachment.html>
More information about the dmd-internals
mailing list