void main() { char c = cast(int)" "; } gives: stringtocharcast.d(3): Error: e2ir: cannot cast " " of type char[1u] to type int Since that is the only error message I could find with e2ir: in front of it, I'll assume it's unintentional. The error message occurs on line 3901 of e2ir.c in the dmd 1.064 source. default: if (fty == tty) goto Lpaint; //dump(0); //printf("fty = %d, tty = %d\n", fty, tty); error("e2ir: cannot cast %s of type %s to type %s", e1->toChars(), e1->type->toChars(), t->toChars()); goto Lzero; Not sure if this is in D2 as well.
*** Issue 7514 has been marked as a duplicate of this issue. ***
Similar case: int main() { float[1] a; return cast(int)a; } test2.d(3): Error: e2ir: cannot cast a of type float[1u] to type int
Issue 7514 isn't a dup and can't at least because it's D2 issue.
And what benefits brings cast from static float array as a whole to single integer? I can understand advantages of casting static float array with exactly 1 element, but why bother to make a special case? Is it too compilcated to have 'arr[0]' instead of 'arr' and having consistency?
The code void main() { char c = cast(int)" "; } is likely to be flawed because what it may produce taking into account D language is conversion from dynamic char array (it may be first/last 4 bytes of address/length depending on what cast from dynamic array mean) to 4 byte integer and then truncate to 1 byte char implicitly.
(In reply to comment #4) > And what benefits brings cast from static float array as a whole to single > integer? An ICE. This report is only about it.
Duplicate or wontfix, D1 is dead and 7514 is the same issue. *** This issue has been marked as a duplicate of issue 7514 ***
(In reply to comment #7) > Duplicate or wontfix, D1 is dead and 7514 is the same issue. > > *** This issue has been marked as a duplicate of issue 7514 *** Yes but we still have lots of "D1 only" issues. You can propose to WONTFIX them all but closing only this one is inconsistent.
Andrei has been closing them, D1 is dead.